Python COM troubles
remove.me.wwicker at spectratechnologies.com
Wed Apr 26 14:34:15 EDT 2000
I'm trying to use Python with SolidWorks, a really cool CAD package.
SolidWorks has a COM interface which plays reasonably well with
Unfortunately, the interface does not seem to provide run-time type
info. This appears to confuse the gen_py interface, which means that
all of my dispatch objects are dynamic. (bummer)
In turn, this looks like it means that I cannot use
DispatchWithEvents, as it seems to rely on the gen_py library being
Is there a way around this appearance of typelessness? There is a type
library, and I've run make-py successfully. I just can't see an easy
way into it.
It should by now be evident that I know little about Python, and less
about COM. Enlightenment welcome.
And now for something completely different:
COM dispatch methods that are documented to return SAFEARRAYS of
dispatch pointers fail with pythonwin v125 and 128 (the only ones I've
felt safe enough to try). The traceback is something like this:
>>> import win32com.client
>>> swx = win32com.client.Dispatch("SldWorks.Application")
>>> adoc = swx.ActiveDoc #get the active model
>>> sel = adoc.SelectionManager #get the current list of selected objects
>>> sel.GetSelectedObjectCount #how many are there?
>>> face = sel.GetSelectedObject3(1) #I already know that I selected a face, so lets get it.
>>> edges = face.GetEdges() #should return a tuple full of dispatch pointers to edge objects...
Traceback (innermost last):
File "<interactive input>", line 1, in ?
File "C:\tools\Python\win32com\client\dynamic.py", line 393, in
SystemError: NULL result without error in call_object
More information about the Python-list