Hello community, please help if you can!

I'm adapting a script that I found online here
<https://gist.githubusercontent.com/thengineer/7157510/raw/05dcde3bf47a8db04af98462e23103296996857b/autocadblockreader.py>
.

I'm trying to change it so that it can open a document, and then change it.

Here's what I have:

import win32com.client
acad = win32com.client.DispatchEx("AutoCAD.Application")
acad.Visible = True

doc = acad.Documents.Open("*path*")   # Document object

# iterate trough all objects (entities) in the currently opened drawing
# and if its a BlockReference, display its attributes and some other things.
for entity in acad.Database.Blocks:
    name = entity.EntityName
     if name == 'AcDbBlockReference':
         HasAttributes = entity.HasAttributes
         if HasAttributes:
             for attrib in entity.GetAttributes():
             string = str(attrib.TextString)
             print(entity.Name)
             print(entity.Layer)
             print(entity.ObjectID)
             print("  {}: {}".format(attrib.TagString, attrib.TextString))
             #update text
             attrib.TextString = "success!"
             attrib.Update()


I'm getting the error attached.

Does anybody know where I'm going wrong?

Thanks,

Josh
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to