Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I am trying to select multiple instances of text (dtext) with different strings but want to change all of the fomats to the same settngs. I have searched high and low on the web to no avail. I am using AutoCAD 2012.
For example: I want the routine to find all instances of "AA", "AB", "AC", "AD", "BA", "BB", "BC", "BD", etc... all the way up to "ZD".
Next I want all of those text entities to change to the following text formats:
- Text Style = STANDARD_96
- Layer = F-ANNO-CKT
- Text Justification = MIDDLE CENTER
- Text Width = .8
Getting this to work with just finding one string at a time with the ssget function seems simple enough, but it's getting it to work with multiple strings that I can't get past. Any help or direction to a similar routine I can modify would be greatly apprechiated.
Rob
Solved! Go to Solution.
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
paste in the command line (ssget "x" '((0 . "text")(1 . "@@")))
then use select Previous
@@ means any two alphabetic characters
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Caddhelp wrote:....(ssget "x" '((0 . "text")(1 . "@@")))
....
@@ means any two alphabetic characters
That will, of course, find any two-alphabetic-character strings, which may include some that don't qualify [with lower-case characters, and/or second characters past D]. One way to check individual text strings in the resulting selection set, and process them only if they're the right kind of letter combination, is to put a Text entity's text content into a variable that I'll call 'txt', and then:
(if
(and
(< 64 (ascii (substr txt 1 1)) 91); first character upper-case A to Z
(< 64 (ascii (substr txt 2)) 69); second character upper-case A to D
); and
(.... change its properties, by whatever means ....)
); if
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks to point it out, I did not read the post carefuly
This ssget will select any text that has two characters: first between A and Z and second between A and D
(ssget "x" '((0 . "text")(1 . "[A-Z][A-D]")))
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for the help. It's been several years since I played with Lisp, so unfortunately I am very rusty. I copied and pasted the (ssget "x" '((0 . "text")(1 . "[A-Z][A-D]"))) into the command line, and the result is a selection set number, but it doesn't actually select anything. However if I type in SELECT, then P, I am then able to select the objects and then invoke the DDCHPROP command (CHPROP command limits the amount of properties you can change via command line).
So I started to wonder if maybe I can just run this in a script file instead of spending hours trying to recall autolisp due to it's simplicity. But when I type into the script file exactly what I typed on the command line, I get a command not found error for DDCHPROP. Here is my script:
(ssget "x" '((0 . "text")(1 . "[A-Z][A-D]")))
select
p
ddchprop
I know I must be missing something very simple here, and I plan to accept my embarrasment like a man. If I have to continue with writing a lisp routine I will, but I was looking for a quicker fix naturally.
Thanks
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
command DDCHPROP
in the top left corner there is a button, QuickSelect, press it.
in the next dialog
Apply to : Entire Drawing
Object Type :Text
Properties : Contents
Operator : * Wildcard Match
Value : [A-Z][A-D]
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Wow...I knew there was an easier way...but geez...it was THAT easy? I feel more ashamed than embarrased!
Thanks for the help!
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
mark it as solved
Re: Finding multiple text strings and change formats
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
rseyda wrote:...
...
Next I want all of those text entities to change to the following text formats:
- Text Style = STANDARD_96
- Layer = F-ANNO-CKT
- Text Justification = MIDDLE CENTER
- Text Width = .8
...
Rob
I suppose the text width would depend on the STANDARD_96 text style in which you dont need to modify that entry.. otherwise you need to override DXF 41 or ScaleFactor (VL) for every selected text entity.
