Solid Edge API: My first add in


Published on

Solid Edge API: My first add in

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Solid Edge API: My first add in

  1. 1. My First Add-InJason NewellThe Charles Machine Works, IncDitch WitchApplications Architect #SEU12
  2. 2. BackgroundThe Charles Machine Works, Inc. (Ditch Witch)• 1997 – Hired into IT support for Engineering department• 1999 – Took over administration of multi-million dollar Unix based PDM system • * The beginning of my programming journey started here• 2000 – Started learning how to automate Solid Edge• 2002 – Moved to full-time programming position• 2005 – Implemented SAP• Present – Little bit of everything with a focus on Microsoft technologiesJasonNewell.NET• 2005 – Created website and forums• Consulting work for customers world-wide © Siemens AG 2012. All Rights Reserved.Page 2 Siemens PLM Software
  3. 3. OverviewWe will be thoroughly covering the basics of Solid Edge Add-Ins. Nothing fancybut you will understand how Solid Edge Add-Ins work when you leave and knowwhat the bare minimum code it requires to write one.There is so much that needs to be understood before attempting to write an add-in. So many situations and scenarios. So many programming languages tochoose from.What programming language is used in this presentation ?Survey says: Visual Basic .NET © Siemens AG 2012. All Rights Reserved.Page 3 Siemens PLM Software
  4. 4. Solid Edge Add-In - DefinitionWhat in the an Add-In?Standard Definition“Solid Edge defines an add-in as a dynamically linked library (DLL) containing aCOM-based object that implements the ISolidEdgeAddIn interface.” - addin.docExtended DefinitionBesides the technical definitions, the add-in architecture allows you to executecode in process “in-proc” with Solid Edge rather than out of process “out-of-proc”like macros. © Siemens AG 2012. All Rights Reserved.Page 4 Siemens PLM Software
  5. 5. Solid Edge Add-In Pros ConsPros• Add-In gets loaded when Solid Edge is started (typically or can be later). Point is no user interaction is required to start the add-in.• You can achieve a higher level of integration with Solid Edge compared to say a macro.Cons• Generally speaking, if you crash, you’re taking Solid Edge down with you.Challenges• The current add-in architecture was designed with native COM friendly languages in mind. Writing add-ins in .NET is challenge because of this fact.• Getting a .NET cat to bark like a COM dog (no pun intended) is damn hard! © Siemens AG 2012. All Rights Reserved.Page 5 Siemens PLM Software
  6. 6. Managed vs NativeCode written in .NET compiles to Microsoft Intermediate Language (MSIL) and isreferred to as “Managed” code. The code is Just-in-time (JIT) compiled atruntime whereas “Native” code is compiled directly to machine code.Solid Edge is a native application so any interaction with .NET must go throughan interoperability (Interop) layer. This interoperability layer is the one of thebiggest pain points in .NET add-in development compared to native add-indevelopment. © Siemens AG 2012. All Rights Reserved. Page 6 Siemens PLM Software
  7. 7. .NET Framework Versions and Dependencies © Siemens AG 2012. All Rights Reserved.Page 7 Source: Siemens PLM Software
  8. 8. Basic Architecture of .NET .NET .NET .NET .NET .NETFramework Framework Framework Framework Framework 2.0 3.0 3.5 4.0 4.5 CLR v2 CLR v4 Shared Components © Siemens AG 2012. All Rights Reserved.Page 8 Siemens PLM Software
  9. 9. Process Overview Edge.exe – Native Process NativeNative.dll mscoree.dll – (Default “vanilla“ shim) Addin.dll CLR v2 CLR v4 (Default app domain) (Default app domain) MyAddin_20 MyAddin_30 MyAddin_35 MyAddin_40 MyAddin_45 © Siemens AG 2012. All Rights Reserved.Page 9 Siemens PLM Software
  10. 10. Application Domains & Runtime Callable Wrappers AppDomain 1 Addin1 RCW Ref Count = 1 Addin2 COM Object Ref Count = 2 AppDomain 2 Addin3 RCW Ref Count = 1 Addin4 © Siemens AG 2012. All Rights Reserved.Page 10 Siemens PLM Software
  11. 11. Visual Studio Bugs!Visual Studio 2010 has a bug that will cause the Type Library Importer(tlbimp.exe) to generate interop assemblies in the wrong format. I only noticedthe bug when having Solid Edge x64 installed. This will cause regasm.exe tofail. To correct this, you have to manually edit your . vbproj and add the followingline.<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" DefaultTargets="Build"xmlns=""> <PropertyGroup> <PlatformTarget>AnyCPU</PlatformTarget> …. </PropertyGroup></Project> © Siemens AG 2012. All Rights Reserved.Page 11 Siemens PLM Software
  12. 12. Live Demos! © Siemens AG 2012. All Rights Reserved.Page 12 Siemens PLM Software
  13. 13. Thank You!Questions? #SEU12