Add string to all nested attributes within a block

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a client that uses blocks for their equipment. Nested in the blocks are separate blocks, each with two attributes: one with a brief part description and an invisible one with a part number. We use DATAEXTRACTION to gather up all the part numbers to create a parts list. Every once in a while, the client will require a piece of equipment to be custom. What we do is add "-X" to the end of each part number; this way when the parts list is created, it clearly shows which items are custom. I have pieced together some code that allows the user to select a nested attribute, and "-X" gets added to the end of its value:
(defun C:AddText2Att ( )
(setq STRG "-X") ;text to be added to the end of existing attribute value
(setq ATTVAL (assoc 1 (setq entlist (entget (car (setq NLIST (nentsel)))))))
(setq NEWVAL (cons 1 (strcat (cdr ATTVAL) STRG)))
(entmod (subst NEWVAL ATTVAL entlist))
(entupd (car (last NLIST)))
)
This works fine, but it would be great if I can just select the block and "-X" gets added to all the part number attributes within the block instead of having to pick each attribute individually. I have attached a quick example plan for reference. In the example, it would be excellent if I could run the routine, select Cabinet1, and "-X" gets added to the end of each ITEM# attribute value.
Any help or direction would be greatly appreciated. Thanks in advance!
Marty