Author Topic: changing text style of selected text  (Read 5512 times)

0 Members and 1 Guest are viewing this topic.

andrew_nao

  • Guest
changing text style of selected text
« 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?


fixo

  • Guest
Re: changing text style of selected text
« Reply #1 on: January 14, 2013, 06:00:20 PM »
Something like this not sure abou:
Code: [Select]
(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)

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: changing text style of selected text
« Reply #2 on: January 14, 2013, 06:17:32 PM »
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:
Code: [Select]
(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)
)

andrew_nao

  • Guest
Re: changing text style of selected text
« Reply #3 on: January 15, 2013, 11:08:56 AM »
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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: changing text style of selected text
« Reply #4 on: January 15, 2013, 11:42:27 AM »
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've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: changing text style of selected text
« Reply #5 on: January 15, 2013, 11:51:55 AM »
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.

fixo

  • Guest
Re: changing text style of selected text
« Reply #6 on: January 15, 2013, 12:42:27 PM »


btw. i meant font, not style.. sorry for the confusion. i was in a hurry :)


Try this code for your style:
 
Code: [Select]
(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)
   )
)
      )
    )

andrew_nao

  • Guest
Re: changing text style of selected text
« Reply #7 on: January 16, 2013, 08:54:33 AM »
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.

andrew_nao

  • Guest
Re: changing text style of selected text
« Reply #8 on: January 16, 2013, 08:55:51 AM »
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

andrew_nao

  • Guest
Re: changing text style of selected text
« Reply #9 on: January 16, 2013, 08:56:53 AM »


btw. i meant font, not style.. sorry for the confusion. i was in a hurry :)


Try this code for your style:
 
Code: [Select]
(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