> I posted the following question on Python Tutor mailing list and > haven't been able to solve the problem. This is probably a more > appropriate list for my > question: > > I'm trying to translate the following VB code into Python and not sure
> how to create an array of variants. If you haven't already done so, I suggest checking out the ctypes tutorial at http://starship.python.net/crew/theller/ctypes/tutorial.html particularly the arrays section, as comtypes is built on top of ctypes. > 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 from ctypes import c_long from comtypes import VARIANT ### double check > 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]) dataType = (c_long * 2)() dataType[0] = 1001 dataType[1] = 1070 dataValue = (VARIANT * 2)() dataValue[0] = 'Test_Application' dataValue[1] = 600 > line.SetXData(dataType, dataValue) Hope this gets you closer... -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre National Licensing and Allocations Branch tel: +61 2 6219 5356 Inputs to Industry Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: [EMAIL PROTECTED] If you have received this email in error, please notify the sender immediately and erase all copies of the email and any attachments to it. The information contained in this email and any attachments may be private, confidential and legally privileged or the subject of copyright. If you are not the addressee it may be illegal to review, disclose, use, forward, or distribute this email and/or its contents. Unless otherwise specified, the information in the email and any attachments is intended as a guide only and should not be relied upon as legal or technical advice or regarded as a substitute for legal or technical advice in individual cases. Opinions contained in this email or any of its attachments do not necessarily reflect the opinions of ACMA. ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users