I am newish with python (ActivePython v2.6), and I am trying to automate AutoCAD 2010 (Acad) using module win32com (using acad's COM/ActiveX interfaces). Most of the interface is pretty straight forward, but I am getting hung up on functions that need to use VARIANTS to pass numerical arrays. Im not sure if my problem is on the python side or my misuse of Acads ActiveX.
For several functions python handles variant conversion automagically, ex, for VARIANT strings I just use python strings and the function works as expected. It is with 2D/3D coordinate sets that I seem to be getting type exceptions.
A simple example would be (acad).ActiveDocument.ModelSpace.AddLine(point1, point2), with point1 and point2 as 3D VARIANTs of type "acDouble".
Currently I cannot get this method to execute without an error or exception (Normally argument mismatch or invalid type). I have tried passing values as python lists,arrays, and even numerical strings, with none working.
So then, Acad has another method that helps you create VARIANT arrays, and its interface is defined as, CreateTypedArray(VarArr, Type, Value1, [value2, value3, ...valueN]), with 'VarArr' as the output variant array, 'Type' as "acDouble", and 'ValueN' as the numerical data to be converted.
I CAN get this function to return quietly, but the actual return value is "None" and the supposed 'VarArr' output array is always the same value I initialized it with. It seems that this is the magic function I am missing, but I cannot get useful return values from it.
On one more note, there is a GetPoint method that returns a 3D variant array after coordinate selection within Acad. I can get this to work properly, and it will return the correct coordinate values from Acad, but when trying to assign the return values and then reusing in the AddLine method, I am still getting the same ol errors, as if the return value is NOT a variant.
I almost feel as if I am misusing python's types, ecspecially dynamic types created from win32com utilities.
Any help is much appreciated.