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. 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. If within a nonuniformly scaled block, explodes into ellipses. Explodes into a single-surface body (nonplanar surfaces), regions, or curves. (MINSERT is not available in AutoCAD LT.) Body. Blocks insert with MINSERT cannot be exploded. 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. Blocks inserted with external references (xrefs) and their dependent blocks cannot be exploded. 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. When I read the documentation, it seems like they should both be finding the same object. I don't understand why the second one works and the first one doesn't. Open it in the Block Editor BEDIT command, and in the Properties palette, change the 'Allow exploding' value: But also, consider whether there may have been a good reason for the Block to have been defined to not allow exploding that's an option in the BLOCK dialog box when you create a Block definition. If entity.EntityName = 'AcDbBlockReference':
HOW TO EXPLODE A BLOCK IN AUTOCAD 2018 CODE
If I change the code to simply walk through all the objects, then it works: acad = ("AutoCAD.Application") 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. 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. Use this procedure to break an inserted block reference into its component parts without affecting the block definition. 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.