Jump to content
LeeNichols

Find/replace text in blocks

Recommended Posts

LeeNichols

I have a block with about 60 single-line text entities, 40 of which have a place holder character that needs to change based on how the block is used. For example, "~1a" and "~1b" need to change to "P1a" and "P1b", where "~" is the place holder and "P" is the letter for this 1 block. The next instance of the same block will need a different letter. This is not a good application for attributes. I found Lee Mac's LISP c:ReplaceBlockText in this thread using vlax-for, but it appears to work on the block definition and changes the text for every instance of the block in the drawing. I need this to work on 1 selected instance of the block. Any help is appreciated, even if it's a point in the right direction.

Share this post


Link to post
Share on other sites
Lee Mac
19 hours ago, LeeNichols said:

I have a block with about 60 single-line text entities, 40 of which have a place holder character that needs to change based on how the block is used. For example, "~1a" and "~1b" need to change to "P1a" and "P1b", where "~" is the place holder and "P" is the letter for this 1 block. The next instance of the same block will need a different letter. This is not a good application for attributes. I found Lee Mac's LISP c:ReplaceBlockText in this thread using vlax-for, but it appears to work on the block definition and changes the text for every instance of the block in the drawing. I need this to work on 1 selected instance of the block. Any help is appreciated, even if it's a point in the right direction.

 

If the single-line text is part of the block, then changing the text content will change it for all references of the block - this is how blocks work.

 

If you require a different value for each block, you should use block attributes as the only other alternative is to create a new block definition for each possible value, which defeats the point of using a block at all.

 

Why do you state :

 

Quote

This is not a good application for attributes

 

Share this post


Link to post
Share on other sites
LeeNichols

Lee Mac, thanks for the reply. After further research, I came to that understanding yesterday. I was hoping to tweak the text in the block using LISP based on a 1-character answer from the user. I didn't want the user to have to modify almost 40 attributes. However, it's easy enough to do with AutoCAD's Find/Replace function. Thanks again

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...