Programming AutoCAD 2007 by compypes 0.5.1 I faced the following problem: The test variable is an object of IAcadBlockReference, which has a method GetAttributes() in the form of (from the generated Python wrapper):
COMMETHOD([dispid(9), helpstring(u'Gets Attributes in the block')], HRESULT, 'GetAttributes', ( ['retval', 'out'], POINTER(VARIANT), 'pAttrObjs' )), The returning VARIANT is an array containing objects of VT_DISPATCH. This type of VARIANT is handled by comtypes.automatation as demonstrated by the following exception: >>> result = test.GetAttributes() Traceback (most recent call last): File "d:\MyProjects\Gromaqua\ACAD-comtypes\<string>", line 1, in <module> File "d:\Python25\Lib\site-packages\comtypes\automation.py", line 394, in __ctypes_from_outparam__ result = self.value File "d:\Python25\Lib\site-packages\comtypes\automation.py", line 345, in _get_value typ = _vartype_to_ctype[self.vt & ~VT_ARRAY] KeyError: 9 Indeed, in line 683 of automatation.py you find: # These are not yet implemented: ## POINTER(IUnknown): VT_UNKNOWN, ## POINTER(IDispatch): VT_DISPATCH, I found that simply uncommenting the above lines solves my problem: test.GetAttributes() returns a tuple of comtypes.POINTER(IDispatch) objects, and comtypes.client.GetBestInterface() makes a good job in converting them into the proper AutoCAD objects. So what does it mean that the above types of VARIANT are not implemented? Regards, Géza Groma Institute of Biophysics Biological Research Center of the Hungarian Academy of Sciences Temesvári krt. 62. 6701 Szeged, Hungary phone: +36 62 599 620 fax: +36 62 433 133 mobile: +36 20 5648 303 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users