reclosedev / pyautocad

AutoCAD Automation for Python ⛺
http://pypi.python.org/pypi/pyautocad/
BSD 2-Clause "Simplified" License
506 stars 143 forks source link

facing COM error #31

Open jaivishnuks opened 4 years ago

jaivishnuks commented 4 years ago

Hi i tried a small code as shown below `from pyautocad import Autocad, APoint

acad = Autocad(create_if_not_exists=True) acad.prompt("Hello, Autocad from Python\n") print(acad.doc.Name)

for obj in acad.iter_objects(): print(obj.ObjectName)`

I am getting an error. COMError: (-2147417851, 'The server threw an exception.', (None, None, None, 0, None))

I am using python 3.7.7 , win10 64 bit and autocad mechanical 2019 with vba enabler engine installed.

ninuo commented 4 years ago

I encounter the same question, and I solved it by different way. for obj in acad.iter_objects(): print(obj.ObjectName)`

This reason may be we have installed more than one version of AutoCAD, so I changed :

for obj in self.acad.model: print(obj.ObjectName)