I just tested under comtypes 0.3 and 0.4 with Autocad 2008. I get this
exception for both when using CreateObject:
######################################################################
Post by KeliePost by Kelieacad = client.CreateObject("AutoCAD.Application")
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 203,
in CreateObject
return _manage(obj, clsid, interface=interface)
File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 171,
in _manage
obj = wrap(obj)
File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 122,
in wrap
typeattr = tinfo.GetTypeAttr()
File "D:\Python25\Lib\site-packages\comtypes\typeinfo.py", line 262, in
GetTypeAttr
return _deref_with_release(self._GetTypeAttr(), self.ReleaseTypeAttr)
COMError: (-2147418111, 'Call was rejected by callee.', (None, None, None, 0,
None))
######################################################################
I think this happens because comtypes is trying to talk to Autocad before it
is finished its post startup initialization (loading modules, CUI, lisp
files).
Using client.GetActiveObject on the other hand successfully generates the
Autocad modules and returns a pointer to the first running instance. It
doesn't work if Autocad isn't running though.
BTW Thomas: I had to switch back to version 0.3.3 because something broke
between that version and the current. When I try to get a pointer to
Microstation under 0.4.1 I get this:
######################################################################
Post by KeliePost by Kelieusta = client.GetActiveObject("MicroStationDGN.Application")
# Generating comtypes.gen._CF9F97BF_39F2_4B8E_835C_8BE9E99DAF5B_0_8_0
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 166,
in GetActiveObject
return _manage(obj, clsid, interface=interface)
File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 171,
in _manage
obj = wrap(obj)
File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 134,
in wrap
mod = GetModule(tlib)
File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line
100, in GetModule
is_current, mod = _CreateWrapper(tlib, pathname)
File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line
218, in _CreateWrapper
mod = _my_import(fullname)
File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line 14,
in _my_import
return __import__(fullname, globals(), locals(), ['DUMMY'])
File
"D:\Python25\lib\site-packages\comtypes\gen\_CF9F97BF_39F2_4B8E_835C_8BE9E99DAF5B_0_8_0.py",
line 223, in <module>
( ['retval', 'out'], POINTER(_midlSAFEARRAY(POINTER(_DataBlock))), 'pVal'
)),
File "D:\Python25\Lib\site-packages\comtypes\safearray.py", line 18, in
_midlSAFEARRAY
sa_type = _make_safearray_type(itemtype)
File "D:\Python25\Lib\site-packages\comtypes\safearray.py", line 46, in
_make_safearray_type
raise TypeError(itemtype)
TypeError: <class 'comtypes.POINTER(_DataBlock)'>
######################################################################
Something to do with the safearray refactor?
Ed Blake
Post by KeliePost by KelieHello group,
I'm getting an error when trying to launch AutoCAD using comtypes. The
application does get started. But the variable 'app' does not seem to
hold a
Post by Kelievalid instance of it, because I was not able to access its properties
such as
Post by KelieActiveDocument, WindowState, etc..
import comtypes
comtypes.__version__
'0.4.2'
app = comtypes.client.CreateObject("AutoCAD.Application")
# Generating comtypes.gen.AutoCAD
File "<interactive input>", line 1, in <module>
File
"C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
Post by Kelieline 202, in CreateObject
return _manage(obj, clsid, interface=interface)
File
"C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
Post by Kelieline 170, in _manage
obj = GetBestInterface(obj)
File
"C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
Post by Kelieline 133, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: 'module' object has no attribute 'IAcadApplication'
Any idea why?
Hm, the exception seems to be raised when the module is generated. Please
look
into the comtypes\gen directory, do you find a (valid) AutoCAD.py file, and
the file
that is imported by AutoCad.py?
If so, can you please look into the latter if there is a 'IAcadApplication'
interface
defined?
If not, you should probably set a breakpoint on line 132 in
comtypes\client\__init__.py,
and inspect the generated module (which has not yet been written to disk).
Or put a line
print dir(mod)
must before line 133 in this file. This should provide some insight.
Thomas
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
Post by Kelie_______________________________________________
comtypes-users mailing list
https://lists.sourceforge.net/lists/listinfo/comtypes-users