Tim Riley wrote:
> Has anyone come up with a way to add AutoCAD points using Python and
> win32? Do I have to use Makepy on the type library? For example adding a
> line to Modelspace requires you to call the AddLine method that accepts
> two arrays of doubles.
>
> Any help/tips would be greatly appreciated.
AutoCAD underspecifies the type of variant it's expecting for such
functions -- the type library requests only a variant instead of an
array of doubles (whereas the documentation is quite clear about what is
needed.)
I've been sitting for **way too long** on a patch that allows you to
specify the type of variant you'd like, permitting something like:
<code>
import pythoncom
import win32com.client
from win32com.client.variant import MakeVariant
acad = win32com.client.Dispatch('autocad.application')
dwg = acad.ActiveDocument
ms = dwg.ModelSpace
point1 = (0,0,0)
point2 = (1,1,0)
point1 = MakeVariant(pythoncom.VT_ARRAY | pythoncom.VT_R4, point1)
point2 = MakeVariant(pythoncom.VT_ARRAY | pythoncom.VT_R4, point2)
line = ms.AddLine(point1, point2)
</code>
Since I'd last looked at this, AutoCAD 2007 got released and the issue
wasn't resolved on their end. Unfortunately, Open Design Alliance'
DWGDirectX library duplicates that bug.
I *finally* started looking at this again just last week and am in the
process of writing a test suite for it. I'll be emailing Mark Hammond
with my progress (initial efforts way back when were overly rigid and
testing wasn't up to snuff). I'll copy you on that update when I send
it tomorrow. It's so nice to have a break from CAD work. :)
Mark and I had taken that discussion off the list way back in February,
and I'll leave it to him if he wants it back on the list.
Cheers!
-drg
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32