TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: andrew_nao on January 14, 2013, 03:59:08 PM
-
im a bit lazy and in a bit of a hurry
does anyone have a quick and simple lisp to change the text style of selected text from simplex to arial black?
-
Something like this not sure abou:
(vl-load-com)
(vla-setfont
(vla-item
(vla-get-textstyles
(setq adoc (vla-get-activedocument
(vlax-get-acad-object))))
"Standard" ;style
)
"ARIAL" ;font
:vlax-false ;bold
:vlax-true ;italic
0 ;charset
(+ 2 64) ;font family
)
(vla-regen adoc acallviewports)
-
change the text style of selected text from simplex to arial black?
Text Style or font assigned to a Text Style? (since the two items you mention are font names)
If they are indeed the names of Text Styles:
(defun c:foo ( / e i s )
(if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT") (7 . "SIMPLEX"))))
(repeat (setq i (sslength s))
(setq e (entget (ssname s (setq i (1- i)))))
(entmod (subst '(7 . "Arial Black") (assoc 7 e) e))
)
)
(princ)
)
-
thanks for the reply, however neither worked
the style is still simplex
ill just change it over to mtext and do it manually
thanks for the offers :)
btw. i meant font, not style.. sorry for the confusion. i was in a hurry :)
cheers
-
btw. i meant font, not style.. sorry for the confusion. i was in a hurry :)
Andrew you should know that the font in plain text can only be changed by changing the STYLE.
You can create a new Style for your desired font or use an existing style.
-
ill just change it over to mtext and do it manually
:-o
Just change the font applied to the Text Style and this change will be reflected across all Text objects referencing the style.
-
btw. i meant font, not style.. sorry for the confusion. i was in a hurry :)
Try this code for your style:
(setq txtstyle (vla-item (vla-get-textstyles adoc) "Standard"));<-- set your style name here
(if (not
(equal (strcase (vla-get-fontfile txtstyle)) "TIMES.TTF"))
(vl-catch-all-apply
'(lambda ()
(progn
(setq fontfile (findfile (strcat (getenv "WINDIR") "\\fonts\\times.ttf")))
(vla-put-fontfile txtstyle fontfile)
)
)
)
)
-
ill just change it over to mtext and do it manually
:-o
Just change the font applied to the Text Style and this change will be reflected across all Text objects referencing the style.
thank Lee, however im after just changing the font on selected text not all the text.
-
btw. i meant font, not style.. sorry for the confusion. i was in a hurry :)
Andrew you should know that the font in plain text can only be changed by changing the STYLE.
You can create a new Style for your desired font or use an existing style.
i was trying to get around that, i guess its not possible.
thanks for the reply
-
btw. i meant font, not style.. sorry for the confusion. i was in a hurry :)
Try this code for your style:
(setq txtstyle (vla-item (vla-get-textstyles adoc) "Standard"));<-- set your style name here
(if (not
(equal (strcase (vla-get-fontfile txtstyle)) "TIMES.TTF"))
(vl-catch-all-apply
'(lambda ()
(progn
(setq fontfile (findfile (strcat (getenv "WINDIR") "\\fonts\\times.ttf")))
(vla-put-fontfile txtstyle fontfile)
)
)
)
)
thanks fixo ill try this out