Lisp to Change Styles

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

Reply to
BruceF
Loading thread data ...

Apologies for the longish posting!

How about Autodesk's old CHTEXT.lsp?

;;; CHTEXT.lsp ;;; (C) Copyright 1988-1993 by Autodesk, Inc. ;;; ;;; This program is copyrighted by Autodesk, Inc. and is licensed ;;; to you under the following conditions. You may not distribute ;;; or publish the source code of this program in any form. You ;;; may incorporate this code in object form in derivative works ;;; provided such derivative works are (i.) are designed and ;;; intended to work solely with Autodesk, Inc. products, and ;;; (ii.) contain Autodesk's copyright notice "(C) Copyright ;;; 1988-1993 by Autodesk, Inc." ;;; ;;; AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. ;;; AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MER- ;;; CHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. ;;; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE ;;; UNINTERRUPTED OR ERROR FREE. ;;; ;;; by Jan S. Yoder ;;; 09 March 1990 ;;; ;;; REVISIONS ;;; 1.01 22 May 1991 DTP -- Minor bug fixes. ;;; 1.02 18 June 1991 JSY, DTP -- Minor bug fixes. ;;; ;;;------------------------------------------------------------------------

Reply to
no-spam-for-hkjffekafphdkdoemehepegkppboihac

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 : ")) (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))

Reply to
alanjt

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

Reply to
BruceF

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

Reply to
BruceF

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.

Reply to
Chuck

Hmm... I think I can try that.

Thanks.

BruceF

Reply to
BruceF

Let me know how it goes. Cheers, Chuck

Reply to
Chuck

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.