• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Member
    Posts: 5
    Registered: ‎04-23-2012
    Accepted Solution

    Finding multiple text strings and change formats

    239 Views, 8 Replies
    04-23-2012 06:43 AM

    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

    Please use plain text.
    Active Contributor
    MetroVancouverDrafting
    Posts: 38
    Registered: ‎06-29-2010

    Re: Finding multiple text strings and change formats

    04-23-2012 09:26 AM in reply to: rseyda

    paste in the command line (ssget "x" '((0 . "text")(1 . "@@")))

    then use select Previous

     

    @@ means any two alphabetic characters

    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,159
    Registered: ‎09-13-2004

    Re: Finding multiple text strings and change formats

    04-23-2012 09:46 AM in reply to: MetroVancouverDrafting

    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

    Kent Cooper
    Please use plain text.
    Active Contributor
    MetroVancouverDrafting
    Posts: 38
    Registered: ‎06-29-2010

    Re: Finding multiple text strings and change formats

    04-23-2012 10:08 AM in reply to: Kent1Cooper

    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]")))

    Please use plain text.
    Member
    Posts: 5
    Registered: ‎04-23-2012

    Re: Finding multiple text strings and change formats

    04-23-2012 11:35 AM in reply to: MetroVancouverDrafting

    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

    Please use plain text.
    Active Contributor
    MetroVancouverDrafting
    Posts: 38
    Registered: ‎06-29-2010

    Re: Finding multiple text strings and change formats

    04-23-2012 12:52 PM in reply to: rseyda

     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]

    Please use plain text.
    Member
    Posts: 5
    Registered: ‎04-23-2012

    Re: Finding multiple text strings and change formats

    04-23-2012 01:24 PM in reply to: MetroVancouverDrafting

    Wow...I knew there was an easier way...but geez...it was THAT easy?  I feel more ashamed than embarrased!

     

    Thanks for the help!

    Please use plain text.
    Active Contributor
    MetroVancouverDrafting
    Posts: 38
    Registered: ‎06-29-2010

    Re: Finding multiple text strings and change formats

    04-23-2012 02:35 PM in reply to: rseyda

    mark it as solved

    Please use plain text.
    *Expert Elite*
    Posts: 2,128
    Registered: ‎11-24-2009

    Re: Finding multiple text strings and change formats

    04-23-2012 10:38 PM in reply to: rseyda

    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.

     

     

    Please use plain text.