>> I'm trying to translate the following VB code into Python and not sure how to
>> create an array of variants.
>>
>> Thanks for your help!
>>
>> VB Code:
>> Sub SetXdata()
>> Dim lineObj As AcadLine
>> Set lineObj = ThisDrawing.ModelSpace.Item(0)
>>
>> Dim DataType(0 To 1) As Integer
>> Dim Data(0 To 1) As Variant
>>
>> DataType(0) = 1001: Data(0) = "Test_Application"
>> DataType(1) = 1070: Data(1) = 600
>>
>> lineObj.SetXdata DataType, Data
>> End Sub
>>
>> Python code:
>> import array
>> import comtypes.client
>>
>> def SetXData():
>> activedoc =
>> comtypes.client.GetActiveObject("AutoCAD.Application").ActiveDocument
>> line = activedoc.ModelSpace.Item(0)
>>
>> dataType = array.array('i', [1001, 1070])
>> dataValue = array.array('?', ['Test_Application', 600]) #What should I use
>> for the type code here?
>>
>> line.SetXData(dataType, dataValue)
>>
>> if __name__ == "__main__":
>> SetXData()
>>
> AFAIK comtypes automatically converts lists to COM arrays and you can
> get variant using following statement:
> from comtypes.automation import VARIANT
>
> So following should work
> line.SetXData([1001, 1070], [VARIANT('Test_Application'), VARIANT(600)])
I think Suraj is close. Can you look up somhow the IDL definition of the
SetXData
method, or posth the corresponding line from the generated code?
Does this code work?
line.SetXData([1001, 1070], ['Test_Application', 600])
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/comtypes-users