Thomas Heller schrieb:
> Ed Blake schrieb:
>> AutoCAD 2008 typelib:
>> [id(0x00000403), helpstring("Sets the extended data (XData) associated with
>> an object"), helpcontext(0x00010231)] void SetXData(
>> [in] VARIANT XDataType,
>> [in] VARIANT XDataValue);
>>
>> Taken from Ole2View.
>>>From Autocad Developer Help:
>> Signature
>>
>> object.SetXData XDataType, XData
>>
>> Object
>>
>> All Drawing Objects , AttributeReference, Block, Dictionary, DimStyle,
>> Group, Layer, Linetype, PlotConfigurations, RegisteredApplication,
>> TextStyle, UCS, View, Viewport; XRecord
>> The object or objects this method applies to.
>>
>> XDataType
>>
>> Variant (array of short); input-only
>>
>> XData
>>
>> Array of Variant; input-only
>
> Ah, if XDataType must be an array of short (integers), then this call should
> work:
>
> line.SetXData(array.array("h", [1001, 1070]), ['Test_Application', 600])
>
>
> The rules how the parameters (array.array("h", ...) and [...]) are converted
> into VARIANTs are as follows:
>
> - tuples and lists (which can contain items of any datatype - string,
> integer, float, ...)
> are converted to a VARIANT containing a SAFEARRAY of VARIANTs, typecode
> VT_SAFEARRAY | VT_VARIANT
>
> - array.array instances are converted to a VARIANT containing a SAFEARRAY a
> VARIANTs
> with a typecode as specified in the
> comtypes.automation._arraycode_to_vartype
> dictionary, near line 650:
>
> _arraycode_to_vartype = {
> "d": VT_R8,
> "f": VT_R4,
> "l": VT_I4,
> "i": VT_INT,
> "h": VT_I2,
> "b": VT_I1,
> "I": VT_UINT,
> "L": VT_UI4,
> "H": VT_UI2,
> "B": VT_UI1,
> }
>
> So, an array.array("h", ...) will result in a VARIANT with typecode VT_ARRAY
> | VT_I2.
>
> In the comtypes 0.5 version, this can be easily checked since VARIANT
> instances
> contain the typecode in their repr() string (VARIANT.from_param(arg) is what
> comtypes
> calls internally when 'arg' is passed as parameter to a method which expects
> a VARIANT):
>
>>>> VARIANT.from_param(array.array('i', [1001, 1070]))
> VARIANT(vt=0x2003, (1001, 1070))
>>>> VARIANT.from_param(array.array('h', [1001, 1070]))
> VARIANT(vt=0x2002, (1001, 1070))
>>>> VARIANT.from_param(['foo', 600])
> VARIANT(vt=0x200c, (u'foo', 600))
>>>>
>
> The typecodes are: 0x2000 - VT_ARRAY, 0x3 - VT_I4, 0x2 - VT_I2
Oh, and 0xc is VT_VARIANT.
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/comtypes-users