title: Using Iron Python with Solidworks API
body: <p>I've been working on scripting some repetitive behaviors in Solidworks using python. I spent a while trying to go through the win32com library and managed to get a lot to work, but ran into a roadblock. So I'm now trying to control the API via Iron Python. Just trying to get rolling and have run into an issue. I've tried to run the code below:</p>
  
  <pre><code>import clr
  clr.AddReferenceToFileAndPath('..\\Redist\\SolidWorks.Interop.sldworks.dll')
  clr.AddReference('SolidWorks.Interop.swconst')
  from SolidWorks.Interop import sldworks
  from SolidWorks.Interop import swconst
  
  print sldworks
  swApp = sldworks.ISldWorks()
  swApp.Visible = True
  </code></pre>
  
  <p>On running this code, I get
  "TypeError: Cannot create instances of ISldWorks because it is abstract"</p>
  
  <p>Upon looking at the solidworks documentation <a href="http://help.solidworks.com/2013/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.ISldWorks.html?id=11f79586cf2348529713b8667e1fdba3#Pg0" rel="nofollow">here</a> 
  I see this information:
  "This interface is the highest-level object in the SolidWorks API. This interface provides a general set of functions that allow application-level operations such as create, open, close, and quit documents, arrange icons and windows, change the active document, and create attribute definitions.</p>
  
  <p>Use CreateObject, GetObject, New, or similar functions to obtain the ISldWorks object from a Dispatch application (Visual Basic or C++ Dispatch). Standalone .exe C++ COM applications can use CoCreateInstance. All of the SolidWorks API add-in wizards automatically create the ISldWorks object for you.</p>
  
  <p>Events are implemented with delegates in the Microsoft .NET Framework. See the Overview topic for a list of delegates for this interface."</p>
  
  <p>Now,  while I'm quite familiar with python programming this whole .net thing is a new animal for me so I'm sure I'm doing something simple wrong, but I'm certainly struggling to figure out exactly what that is. Thanks for your help. </p>
  
  <p>--UPDATE 
  So I have gone through and looked into how the .net system works, and I feel like I have a better handle on it. So if I understand correctly my goal is to try to create an instance of the Solidworks application object, or ISldWorks, and then I should be able to access all of the members. In my research I've come across these two articles: <a href="http://www.linkedin.com/groups/Create-simple-SolidWorks-StandAlone-Application-4961405.S.235214502" rel="nofollow">Solidworks standalone app</a> and iron python documentation from these, and your very helpful response, it seems like the code below should work. Though when run, I get an error that says "EnvironmentError: System.Runtime.InteropServices.COMException (0x8002802B): Element not found. (Exception from HRESULT: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))" which would lead me to believe that the object still is not instatiating correctly. </p>
  
  <pre><code>import System
  t = System.Type.GetTypeFromProgID('SldWorks.Application')
  swApp = System.Activator.CreateInstance(t)
  swApp.Visible = True
  </code></pre>