Lisp to Change Styles

Discussion in 'AutoCAD' started by BruceF, Aug 17, 2008.

  1. BruceF

    BruceF Guest

    I've been trying to cobble up a LISP routine to change all Text Styles
    to one User defined Style.

    I get drawings from Architects that I use for Backgrounds... I usually
    don't like all the fancy style types that they use and just want to have
    something simple (like RomanS or Simplex).

    So what I would like is to open their file and run a routine that will
    search the TEXT Style database and change them to one of the Styles I
    type in.

    I know how to do this sort of thing for Style using:
    (if (not (tblsearch "style" "MyName")) ....)

    .... and I've used this to create Styles one at a time... but never to do
    a Global change for styles.

    Can someone point me in the right direction? Or provide some sample Code?

    Thanks in Advance...

    BruceF
     
    BruceF, Aug 17, 2008
    #1
  2. BruceF

    alanjt Guest

    i wrote a routine the other day that will do exactly what you are
    wanting. the default text style is set to notes, but you can change it
    to whatever you like, but you can set the text style just by typing it
    in, when prompted. if the style doesn't exist, nothing happens.

    ;set style of all text
    ;will select all text in drawing and change to the specified text
    style
    ;the default text style is set to "NOTES", but can easily be changed
    to desired default text style
    ;created by: alan thompson, 6.10.08

    (defun c:ssat (/ ss1 new_style integer ss-len en elist)
    (setq new_style (getstring "\nDesired text style to change all text
    to <NOTES>: "))
    (if
    (= new_style "")
    (setq new_style "NOTES")
    );if
    (setq ss1 (ssget "x" '((0 . "*text"))))
    (if ss1
    (progn
    (if
    (not
    (tblsearch "STYLE" new_style)
    );not
    (princ (strcat "\nStyle * " new_style " * does not exist!"))
    (progn
    (setq integer 0) ; set counter
    (setq ss-len (sslength ss1))
    (while (< integer ss-len)
    (setq en (ssname ss1 integer)) ; get entity name of object
    (setq elist (entget en)); get entity list
    (setq elist (subst (cons 7 new_style)(assoc 7 elist) elist))
    (entmod elist)
    (setq integer (+ 1 integer)); increment integer
    );end while
    (princ (strcat "\nAll " (rtos (sslength ss1)) " text objects are
    now style: '" new_style "'"))
    );progn
    );if not
    );progn
    (princ "\nSorry, no text in drawing.")
    );if ss1
    (princ))
     
    alanjt, Aug 18, 2008
    #2
  3. BruceF

    BruceF Guest

    I've got that... but I think you missed my question... I'm not looking
    to change TEXT... just the STYLES (command "style").

    I guess I goofed up by not saying that I'm really after looking to
    change the FONT name.

    Thanks anyways.

    BruceF
     
    BruceF, Aug 18, 2008
    #3
  4. BruceF

    BruceF Guest

    Ummm... it does change the drawing Text... but what I'm really looking
    for is to change the Data Base STYLE information. So for example...

    If the Default text style "STANDARD" text is TXT... then when I run the
    Lisp routine, TXT then becomes ROMANS (or Simplex)...

    I guess I goofed up by not saying that I'm really after looking to
    change the FONT name.

    Thanks.

    BruceF
     
    BruceF, Aug 18, 2008
    #4
  5. BruceF

    Chuck Guest

    Maybe (tblenext "style" T) then (tblenext "style") adding to a selection set
    each time until tblenext returns "nil".
    then using (cons 3 "romans.shx") and entmod to update each entity in the
    selection set.
    I haven't used Autolisp in a while so I'm going by memory.
     
    Chuck, Aug 18, 2008
    #5
  6. BruceF

    BruceF Guest

    Maybe (tblenext "style" T) then (tblenext "style") adding to a selection set
    Hmm... I think I can try that.

    Thanks.

    BruceF
     
    BruceF, Aug 18, 2008
    #6
  7. BruceF

    Chuck Guest

    Let me know how it goes.
    Cheers,
    Chuck
     
    Chuck, Aug 19, 2008
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.