Re: How do I access another api using Ironpython and VS2017

jpahto@...
 

"SldWorks.Application" can be activated by the version number.

for SW 2012

("SldWorks.Application.20")

for SW 2013

("SldWorks.Application.21")

for SW 2014

("SldWorks.Application.22")

for SW 2015

("SldWorks.Application.23")

for SW 2016

("SldWorks.Application.24")

for SW 2017

("SldWorks.Application.25")

If I try to use this:
>>> System.Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application.24"))
<System.__ComObject object at 0x000000000000006C [System.__ComObject]>

And then:

>>> swApp = System.Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application.24"))
>>> dir(swApp)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
EnvironmentError: System.Runtime.InteropServices.COMException (0x8002802B): Elementtiä ei löydy. (HRESULT-poikkeus: 0x8002802B (TYPE_E_ELEMENTNOTFOUND))
   kohteessa System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   kohteessa Microsoft.Scripting.ComInterop.ComRuntimeHelpers.GetITypeInfoFromIDispatch(IDispatch dispatch, Boolean throwIfMissingExpectedTypeInfo)
   kohteessa Microsoft.Scripting.ComInterop.IDispatchComObject.EnsureScanDefinedMethods()
   kohteessa Microsoft.Scripting.ComInterop.IDispatchComObject.GetMemberNames(Boolean dataOnly)
   kohteessa IronPython.Runtime.Operations.PythonOps.GetAttrNames(CodeContext context, Object o)
   kohteessa IronPython.Modules.Builtin.dir(CodeContext context, Object o)
   kohteessa Microsoft.Scripting.Interpreter.FuncCallInstruction`3.Run(InterpretedFrame frame)
   kohteessa Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   kohteessa Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   kohteessa System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   kohteessa Microsoft.Scripting.Interpreter.FuncCallInstruction`6.Run(InterpretedFrame frame)
   kohteessa Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   kohteessa Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   kohteessa IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedFrame frame)
   kohteessa Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   kohteessa Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
   kohteessa IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
   kohteessa IronPython.Hosting.PythonCommandLine.<>c__DisplayClass27_0.<RunOneInteraction>b__0()

Join users@ironpython.groups.io to automatically receive all group messages.