ASE, SQL, OLE, ADE
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Python and COM for AcadE
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
467 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++?
:
r better yet, a python guru who knows what I am doing wrong 
Thanks for any help.
Edited by: cpetzol2 on Feb 15, 2010 10:18 PM Edited by: cpetzol2 on Feb 15, 2010 10:23 PM
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++?
:
Thanks for any help.
Edited by: cpetzol2 on Feb 15, 2010 10:18 PM Edited by: cpetzol2 on Feb 15, 2010 10:23 PM
Re: Python and COM for AcadE
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
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.
Re: Python and COM for AcadE
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.
