wccppp,<br><br>I too am working on this same issue as we speak. It is my goal to automate AutoCAD using Python. I've had success using C# (.net) for Automation but I haven't given up with Python yet. I have done searches here and there on various search engines and haven't come up with any complete answers on passing 3 doubles as an array of Variants. This as you see doesn't happen automatically as it should and Mark has mentioned that idispatch invoke() manually is the way to correctly pass them. I have yet to master invoke and all the params. What I need is a working example of Invoke and its parameters. It seems AutoCAD object model is easy to decifer and the passing and retrieval of a Variant(s) in Python are my only stepping stones to complete a successful automation. I am continually monitoring this mailing list and in my research I will pass on any information that I uncover.
<br><br>Drkick16<br><br><br><div><span class="gmail_quote">On 12/11/05, <b class="gmail_sendername"><a href="mailto:python-win32-request@python.org">python-win32-request@python.org</a></b> <<a href="mailto:python-win32-request@python.org">
python-win32-request@python.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Send Python-win32 mailing list submissions to
<br> <a href="mailto:python-win32@python.org">python-win32@python.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> <a href="http://mail.python.org/mailman/listinfo/python-win32">http://mail.python.org/mailman/listinfo/python-win32
</a><br>or, via email, send a message with subject or body 'help' to<br> <a href="mailto:python-win32-request@python.org">python-win32-request@python.org</a><br><br>You can reach the person managing the list at<br>
<a href="mailto:python-win32-owner@python.org">python-win32-owner@python.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Python-win32 digest..."
<br><br><br>Today's Topics:<br><br> 1. question about COM again: variable type? (wccppp)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Sat, 10 Dec 2005 23:30:46 -1000
<br>From: wccppp <<a href="mailto:wccppp@gmail.com">wccppp@gmail.com</a>><br>Subject: [python-win32] question about COM again: variable type?<br>To: <a href="mailto:python-win32@python.org">python-win32@python.org</a>
<br>Message-ID:<br> <<a href="mailto:87bd46aa0512110130u70570e7fy4be4b95f5163b1df@mail.gmail.com">87bd46aa0512110130u70570e7fy4be4b95f5163b1df@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"
<br><br>Hello,<br><br>I'm having problem implementing a "AddPoint" method in AutoCAD. From the<br>search I've done, seems the problem is variable type: I supplied a list as<br>the x,y,z coordinates of a point, why seems what is expected is a Variant
<br>(three-element array of doubles).<br><br>The python code I tested with is:<br><br>[code]<br><br>import win32com.client<br><br>acad = win32com.client.Dispatch("AutoCAD.Application")<br>acad.WindowState = 3<br>
acad.Visible = 1<br><br>doc = acad.ActiveDocument<br>ms = doc.ModelSpace<br>print str(ms.ObjectName)<br>try:<br> ms.AddPoint([0.0, 0.0, 0.0]) # this line gives the problem<br>finally:<br> print "\nTest finished."
<br><br>[/code]<br><br>This is the error I got:<br><br>Traceback (most recent call last):<br> File "<string>", line 65, in run_nodebug<br> File "C:\Programming\Python\Codes\acad_add_point.py", line 11, in ?
<br> ms.AddPoint([0.0, 0.0, 0.0])<br> File "C:\Python24\lib\site-packages\win32com\gen_py\1EFD8E85-<br>7F3B-48E6-9341-3C8B2F60136Bx0x1x1.py", line 12688, in AddPoint<br> ret = self._oleobj_.InvokeTypes(1562, LCID, 1, (9, 0), ((12, 1),),Point
<br>pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None,<br>None, 0, -2147024809), None)<br><br><br>python code for AddPoint method from makepy:<br><br># Result is of type IAcadPoint<br>def AddPoint(self, Point=defaultNamedNotOptArg):
<br> """Creates a Point object at a given location"""<br> ret = self._oleobj_.InvokeTypes(1562, LCID, 1, (9, 0), ((12, 1),),Point)<br> if ret is not None:<br> ret = Dispatch(ret, 'AddPoint',
<br>'{35AF3AB5-755E-4AC9-8BAF-31B532870751}', UnicodeToString=0)<br> return ret<br><br><br>And finally, below is the VBA doucumentation provided with AutoCAD.<br><br>Signature<br><br>RetVal = object.AddPoint(Point)<br>
<br>Object<br><br>ModelSpace Collection, PaperSpace Collection, Block<br>The object or objects this method applies to.<br><br>Point<br><br>Variant (three-element array of doubles); input-only<br>The coordinates of the point to be created.
<br><br>RetVal<br><br>Point object<br>The newly created Point object.<br><br>Example:<br><br>Sub Example_AddPoint()<br> ' This example creates a point in model space.<br> Dim pointObj As AcadPoint<br> Dim location(0 To 2) As Double
<br><br> ' Define the location of the point<br> location(0) = 5#: location(1) = 5#: location(2) = 0#<br><br> ' Create the point<br> Set pointObj = ThisDrawing.ModelSpace.AddPoint(location)<br> ZoomAll<br><br>
End Sub<br><br>Sorry for the long post. I've actually spent more than 2 or 3 hours<br>searching the web for an answer. And I did see lots of discussions related<br>to this sort of issue: safearray, variant array, etc.. But I didn't see a
<br>definite answer. More than likely it is because I'm a beginner in Python<br>and could not make sense out of those discussion. Can someone elaborate a<br>little bit on this?<br><br>Thanks a lot for just reading my long message.
<br><br>--<br><br>Regards,<br>- wcc<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.python.org/pipermail/python-win32/attachments/20051210/f1dca702/attachment-0001.htm">
http://mail.python.org/pipermail/python-win32/attachments/20051210/f1dca702/attachment-0001.htm</a><br><br>------------------------------<br><br>_______________________________________________<br>Python-win32 mailing list
<br><a href="mailto:Python-win32@python.org">Python-win32@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/python-win32">http://mail.python.org/mailman/listinfo/python-win32</a><br><br><br>End of Python-win32 Digest, Vol 33, Issue 14
<br>********************************************<br></blockquote></div><br><br clear="all"><br>-- <br>drkick16