AutoCAD 2010/2011/2012 DWG Format
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I am trying to add text to a set of text strings in a drawing.
The tricky part is that not all of the text strings are the same.
For example, change part numbers
123, 125, 456, 892
to
123-70, 125-70, 456-70, 892-70
Is there a way to do this for all of the strings at once?
Solved! Go to Solution.
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Not aware of a built-in way, but you could use a lisp application.
For several lisp examples that provide the sort of thing you are asking about, see following post:
Text prefix/suffix
http://forums.augi.com/showthread.php?t=6364
Did not try all programs, but the one posted by Peter Jamtgaard seems to work well.
C3D 2012 SP1, Win XP Home
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Please try ALTEXT.vlx
As for your example, select all texts, then in the "Change text content:" dialogue box, set "Modified", "String", Insert at "Middle", set the position as "3", New text as "-".
3wood
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks! I will give this a try.
I do have another twist to this problem though.
Sometimes I need to change the last two numbers to something different. The last two numbers of each string are always the same but they may be the same as two other numbers in the string. This makes it hard to use wildcards.
The number of digits in the string is always the same.
For example:
Change
1234500, 1002500, 5689400
to
1234570, 1002570, 5689470
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Well once again, there may not be a built-in way of substituting the last two characters with something else, but it can be done with programming.
I attached a fairly simple lisp program I created to remove the specified number of characters off of the end of Text or MText entities. So you could use the attached program to remove the specified number of characters and then use one of the prefix, suffix applications previously referenced to add new suffix characters to the end. Yes, the programs could be combined but maybe this is an endeavor for you. I suggest you test out these programs to make sure they are doing what you want them to do without any issues.
The attached program will only work with Text and MText, not Attribute Definitions or Text Entities that are embedded within a block. That can also be done, but there is a bit more programming involved. Not sure what was the significance of the file you attached, but perhaps that is what your next question was.
Anyway, hope that gets you there, or at least points you in the right direction.
C3D 2012 SP1, Win XP Home
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Again, ALTEXT.vlx can achive this quite easily.
Example 1, adding same number to selected texts:
Change
1234500, 1002500, 5689400
to
1234570, 1002570, 5689470
Just simply add "70" as "Increment" to "Number"
Example 2, replace last two digits to a same number no matter what figures they were.
Change
1234510, 1002534, 5689498
to
1234570, 1002570, 5689470
Step 1
Add a speciall character such as "-" to the third place counting from left.
The result will be:
12345-10, 10025-34, 56894-98
Step 2
Replace mode as "New", Change to "Number", Search from "Right", New text as "70", don't select "Dash as negtive symbol"
The result will be:
12345-70, 10025-70, 56894-70
Step 3
Use AutoCAD command FIND to replace text "-" with nothing.
The result will be:
1234570, 1002570, 5689470
3wood
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks! I tried both the RemChar.lsp file and the textps.lsp from Jamtgaard that you suggested earlier.
They both worked great. But there was one quirk in the textps.lsp file.
I was able to start it up in the command window in ACAD but it would never actually change the text. Until I used the RemChar.lsp file. That one worked fine. Then I was able to use the textps.lsp file.
I'm not sure why this is. I have compared both programs. All I can think of is that the textps.lsp file is missing the text (vl-load-com). What can I say. I'm a newbie to this stuff.
Any ideas of what is wrong? Sorry I tried to attach the file but for some reason could not.
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Nevermind. I guess I was able to attach a .txt version of the file textps.lsp. The version I used was a .lsp version.
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Yes, add the (vl-load-com) as the second line of the program. Also the file does need to end in .lsp
C3D 2012 SP1, Win XP Home
Re: Replacing part of a text string
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I added the (vl-load-com) and it worked great! thanks.

