[Tutor] How to create array of variants?

Kelie kf9150 at gmail.com
Tue Jul 8 05:41:58 CEST 2008


Hello group,

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?

    line.SetXData(dataType, dataValue)

if __name__ == "__main__":
    SetXData()




More information about the Tutor mailing list