Add string to all nested attributes within a block

Add string to all nested attributes within a block

Anonymous
Not applicable
724 Views
2 Replies
Message 1 of 3

Add string to all nested attributes within a block

Anonymous
Not applicable

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

0 Likes
725 Views
2 Replies
Replies (2)
Message 2 of 3

dbroad
Mentor
Mentor

I might be off target here but, if I understand you, changing the attributes in blocks nested into an insert would change those attributes in every block reference for that block in the drawing. That is because editing nested objects changes the block definition, not the block reference instance.  If you want separate instances to report as custom, you would need to either create a new block definition to hold the customized blocks or you would need to move the attributes from the nested blocks to the parent blocks.

 

How do you propose to manage that?  Is it OK for every block reference to contain the change intended for perhaps a single block reference?

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you dbroad for your interest.  

You bring up an excellent point.  For example, if I have three instances of Cabinet1 in my drawing, but only one is going to be custom, the attributes will get updated in all instances.  I think we may have to create a unique block each time we have a custom item.  Maybe you click on the block, a copy of the block is created and saved in its place, and then the tags are updated on this custom block.  I'll have to ponder on this a bit more.  Thanks for your input.  

0 Likes