ASE, SQL, OLE, ADE

ASE, SQL, OLE, ADE

Reply
Active Contributor
cpetzol2
Posts: 43
Registered: ‎12-14-2009
Message 1 of 3 (681 Views)

Python and COM for AcadE

681 Views, 2 Replies
02-15-2010 02:17 PM
(Sorry if this is the wrong forum)
Im using python v2.6 to do some automation using the win32com module. Most of the COM works just fine, but I am having problems with any methods that require numerical VARIANTS as arguments (string based VARIANTS work as expected). I believe my issue is related to data types on python's end (with its array's specifically), although I am not entirely sure. I am currently trying to pass a 3-d array using 8-byte doubles, but the methods keep throwing exceptions. This is a rough example invocation...

(acadID).ActiveDocument.ModelSpace.AddPoint( [1.0, 1.0, 0.0] )

Here is the error python returns, although Im not sure if this is actually from python's win32com module or COM itself:
(-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024809), None)

Can anybody relate to similiar problems from VB(A) / C++?
::smileysurprised:r better yet, a python guru who knows what I am doing wrong :smileywink:

Thanks for any help.

Edited by: cpetzol2 on Feb 15, 2010 10:18 PM Edited by: cpetzol2 on Feb 15, 2010 10:23 PM
Active Contributor
cpetzol2
Posts: 43
Registered: ‎12-14-2009
Message 2 of 3 (681 Views)

Re: Python and COM for AcadE

03-24-2010 10:28 AM in reply to: cpetzol2
Note for anyone interested something similar.

It can be done (only? in python 2.6). The issue was with the interface generated by win32com assigning the wrong type to the VARIANT.

You have to find the generated .py file in your path, and edit the variant type by hand. Sad part is that many functions have this error (hundreds), so you will probably only want to edit them as needed (unless you know how to hack win32com or you are great with regular expressions).

Afterwards (could take a while), all will be well in the world.

Good luck.
New Member
Gontar_Anton
Posts: 1
Registered: ‎07-01-2010
Message 3 of 3 (634 Views)

Re: Python and COM for AcadE

07-01-2010 11:51 PM in reply to: cpetzol2

Hi. I`m absolutely new in programming, now I`m trying to use python 2.6 for my needs. And in future a want to use python for programming in AutoCAD. But I don`t know how to use python and ACAD  together.

Please, can you give me advise what I have to read to understand this.

Best regards, Gontar Anton.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.