Géza Groma schrieb:
> 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?

When I wrote the safearray code initially then the above did not work
because the COM refcounts were not managed correctly.  This might be
fixed in the meantime (I'm not really sure) and if it works for you then great.

At least there is currently no unittest for it - does someone know a standard
COM object the returns a (VT_ARRAY | VT_DISPATCH) variant so that I can write
a unittest without the need to implement such a COM object myself?  And no,
I don't have autocad myself.

-- 
Thanks,
Thomas


-------------------------------------------------------------------------
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

Reply via email to