AutoCAD automation via python and win32com: read all attributes from BlockReferences
import win32com.client | |
acad = win32com.client.Dispatch("AutoCAD.Application") | |
doc = acad.ActiveDocument # 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.ActiveDocument.ModelSpace: | |
name = entity.EntityName | |
if name == 'AcDbBlockReference': | |
HasAttributes = entity.HasAttributes | |
if HasAttributes: | |
print(entity.Name) | |
print(entity.Layer) | |
print(entity.ObjectID) | |
for attrib in entity.GetAttributes(): | |
print(" {}: {}".format(attrib.TagString, attrib.TextString)) | |
# update text | |
attrib.TextString = 'modified with python' | |
attrib.Update() |
This comment has been minimized.
This comment has been minimized.
How do i add the win32 module in my python |
This comment has been minimized.
This comment has been minimized.
Hi I don't know how to create blocks with atributes, maybe someone here could help me please?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
You are a prince. Thank you.