1

I want to make an python script to extract information of existing dwg/dxf file. I thought pyautocad can help me, but I cannot find correct way to do this.

I heard that pyautocad use AutoCAD ActiveX so try to use Open method of AutoCAD ActiveX (Here https://help.autodesk.com/view/OARX/2018/HUN/?guid=GUID-9ED7A548-7978-4BFD-8462-E2FA747E8880)

But it said this method should be used in MDI mode...

Then what can i try to open existing dwg/dxf file with python??



from pyautocad import Autocad

acad = Autocad(create_if_not_exists=True)
print(acad.doc.Name) #for test

acad2 = acad.doc.Open('Test.dwg') #I want to open saved dwg or dxf file of my computer
print(acad2.doc.Name)

print('Quit')


C.Nivs
  • 12,353
  • 2
  • 19
  • 44
JY Kim
  • 11
  • 4
  • Docs aren't great but they don't mention an `Open` function https://pyautocad.readthedocs.io/en/latest/api.html#module-pyautocad.utils – kpie Feb 22 '22 at 04:29

1 Answers1

0

I do not use Python but have a little knowledge of the AutoCAD COM/ActiveX API. Try like this:

acad2 = acad.Documents.Open('Test.dwg')
gileCAD
  • 2,295
  • 1
  • 10
  • 10
  • Thanks for your answer. I tried that but it's not possible. I've got the error message "'Autocad' object has no attribute 'Documents'" – JY Kim Feb 23 '22 at 00:37