Python scripts stop working on AutoCAD Mechanical 2018

Python scripts stop working on AutoCAD Mechanical 2018

Anonymous
Not applicable
624 Views
0 Replies
Message 1 of 1

Python scripts stop working on AutoCAD Mechanical 2018

Anonymous
Not applicable

I have python scripts which interact with and control AutoCAD documents through comtypes, if the AutoCAD application is open. They work perfectly in AutoCAD Mechanical 2016. We have recently upgraded to AutoCAD Mechanical 2018 and the wheels have come off the wagon.  (Both running on Windows 10.)

 

The following line, directly after the imports (which I rewrote to include the package name for clarity)

app = comtypes.client.GetActiveObject("AutoCAD.Application")

...now fails with the error message:

COMerror: (-2147467262, 'No such interface supported', (None, None, None, 0, None))

This obviously breaks everything-- no COM, no interface. Clearly something has changed from version to version relating to the com object, but I'm not sure what, or how I can specify the correct object here.

 

Can anyone help?

 

(I will note that I've tested the script in both versions of AutoCAD, both using the same test drawing, and that drawing was actually saved in AutoCAD 2013 format, for non-technical reasons. So it is unlikely to be anything about the file itself.)

0 Likes
625 Views
0 Replies
Replies (0)