PDA

View Full Version : Change text style


pt_zooropa
2008-07-14, 06:49 PM
Hi,
I have this code (change all text style to Standard):
(vl-load-com)
(vlax-for x (vla-get-textstyles
(vla-get-activedocument (vlax-get-acad-object))
)
(vla-put-fontfile x "Simplex.shx")
)

(vl-load-com)
(setq TxtHgt 0.1)
(setq CurSet (ssget '((0 . "TEXT")(-4 . "<=")(40 . 4.7))))
(if CurSet
(while (setq CurEnt (ssname CurSet 0))
(setq CurObj (vlax-ename->vla-object CurEnt))
(ssdel CurEnt CurSet)
(vla-put-alignment CurObj acAlignmentLeft)
(vla-put-StyleName CurObj "STANDARD")
(vla-put-height CurObj TxtHgt)
(vla-Update CurObj)
)
)
(princ)
)
Is there a diferent way to make this better?

rkmcswain
2008-07-14, 07:31 PM
Better in what way?

BTW: the last parenthesis is unneeded. It is not closing anything.

pt_zooropa
2008-07-14, 08:45 PM
Better in what way?

BTW: the last parenthesis is unneeded. It is not closing anything.
This code runs fine in simple text, but not in Mtext.

Lions60
2008-07-14, 09:10 PM
This will let select either text or Mtext


'((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(-4 . "OR>"))

This code will change all text to the standard text style if it isn't currently set as standard.


(defun c:chgtxt ()
(setq text (ssget "X" '((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(-4 . "OR>"))))
(if (setq number (sslength text))
(progn
(setq txtcount 0)
(repeat number
(setq entityname (ssname text txtcount))
(setq entity (entget entityname))
(if (/=(cdr(assoc 7 entity))"Standard")
(progn
(setq entity(subst (cons 7 "Standard") (assoc 7 entity)entity))
(entmod entity)
);; end of progn
);; end of if
(setq txtcount (+ txtcount 1))
);; end of repeat
);; end of progn
);; end of if
);; end of defun

irneb
2008-07-15, 07:47 AM
You could use this as well, the comma is the same as saying OR:'((0 . "TEXT,MTEXT"))

alanjt
2008-07-26, 05:15 AM
;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))


oh yeah, first post.