With the above information, you will need to iterate over the block references found within the relevant layout container, and, if the block reference meets your criteria, iterate over the set of attribute references held by the block reference (which you can obtain using the GetAttributes method), changing the Textstring property of those attributes which meet your criteria. Use this procedure to break an inserted block reference into its component parts without affecting the block definition. Such attribute references may then hold different text content for each block reference inserted in the drawing.Īside, interestingly, attribute references may also be programmatically attached to a block reference independently of the block definition, however, this is not permitted when operating AutoCAD using the standard out-of-the-box front end. Whereas, when iterating over the objects held by the Paperspace Collection (which is itself a type of Block Definition), you are encountering Block Reference objects ( AcDbBlockReference), which do have the HasAttributes property.Ĭonsider that the Block Definition is essentially the "blueprint" for the block, and each Block Reference is an instance displaying the objects found within the block definition, at a specific position, scale, rotation & orientation in the drawing.Īttributes also have Attribute Definitions within the Block Definition, and corresponding Attribute References attached to each Block Reference. When invoking the Item method on the Blocks collection, you are obtaining a Block Definition object ( AcDbBlockTableRecord), which is a container for the set of objects constituting the block geometry and does not have the HasAttributes property. To Explode a Block Reference Products and versions covered By: Help In-product view SHARE Use this procedure to break an inserted block reference into its component parts without affecting the block definition. When I read the documentation, it seems like they should both be finding the same object. If you plan to use this method to update.
I don't understand why the second one works and the first one doesn't. YOU CAN'T UPDATE EXPLODED BLOCKS Exploded blocks won't be updated when you update blocks from an external file. If entity.EntityName = 'AcDbBlockReference': so my suggestions in AutoCAD need new command for Attribute text convert to pure text.Thanks Jayhar.M.J Product and Feature: AutoCAD - Blocks Submitted By: Jayhar on. But Attribute cannot explode or cannot use burst.
If I change the code to simply walk through all the objects, then it works: acad = ("AutoCAD.Application") Summary: Block Attribute Can Convert to Text Description: Block Attribute Can Convert to Text using command 'BURST'. This correctly prints the block name, but attempting to access the HasAttributes property causes this error: AttributeError: Item.HasAttributes My code: acad = ("AutoCAD.Application")Īcad.ActiveDocument = (os.path.normpath(os.path.join(baseDir,filename)))ĭoc = acad.ActiveDocument # Document objectĮntity = ('TTLB ATTRIBUTES')
I want to select a specific block, and then edit some of its attributes. I have tried to follow the method shown here in the AutoCAD documentation: I am trying to automate some tasks in AutoCAD using Python and pywin32.