Data Type Problem in Python / COM

O

Olav

I'm trying to use Python / COM to do some drawing automation. Here
is a simple code example:
This code uses a object made by the Opendwg-org. Autocad has a similar
object with the same methods - and the same result.

-----------

import win32com.client
odaHost=win32com.client.dynamic.Dispatch("DWGdirectX.OdaHostApp")
odaApp = odaHost.Application

point = (0,0,0) #x,y,z

filename = r'c:\temp\test.dwg'
odaDoc = odaApp.Documents.Add(filename)

odaDoc.ModelSpace.AddPoint(point)

--------------

Traceback (most recent call last):
File
"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
File "F:\dom-users\Autoproject\makedwg.py", line 13, in ?
odaDoc.ModelSpace.AddPoint(a)
File
"C:\Python24\Lib\site-packages\win32com\gen_py\2D1051CA-C44F-4206-A86D-45E24A10ABC7x0x2x0.py",
line 9516, in AddPoint
ret = self._oleobj_.InvokeTypes(1562, LCID, 1, (9, 0), ((12,
1),),Point
com_error: (-2147352567, 'Exception occurred.', (0, 'DWGdirectX', 'The
parameter is incorrect.\r\n', None, 0, -2147024809), None)

-------------------

I have tried both early and late binding but with the same result.

I have seen the same code in VB, and the code looks like this:
This works.

------------

Sub Example_AddPoint()
' This example creates a point in model space.
Dim pointObj As AcadPoint
Dim location(0 To 2) As Double
' Define the location of the point
location(0) = 5#: location(1) = 5#: location(2) = 0#
' Create the point
Set pointObj = ThisDrawing.ModelSpace.AddPoint(location)
----------------

It seems to me that this error is related to the data-type
conversation.
Any help would be much appreciated

Thanks
Olav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top