TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Luke on September 02, 2009, 04:34:26 PM

Title: Change font type
Post by: Luke on September 02, 2009, 04:34:26 PM
I currently have a text style called LCC.  It is used all over the place... my standard notes, in my dimension styles and within my title block.

The font type is Romans.  I need to change it to Ariel.  Changing my template so a new drawing is correct is no problem.  But all my old drawings need to be changed. 

Is this a job for a script / lisp or do I need to font map something?  I do not want the romans font totaly replaced by Ariel, I just want to change the fone used in my text style.

Thanks
Title: Re: Change font type
Post by: curmudgeon on September 02, 2009, 05:18:02 PM
I work in autocad 2000 but, if ALL your text is extremely similar, justifications etc., you can use SSX from express tools to create a selection set of the text you want to change, create or insert one piece of text with your new font and MATCHPROP previous.

if they don't call it SSX anymore:

Code: [Select]
(setq ss1 (ssget "X" '((7 . "LCC"))))
should get a similar selection set.
then create the similar style with ariel font type and name it something different, like LCC1.
then modify the text entities with SUBST and ENTMOD.

but the lisp might look like this:

Code: [Select]
(defun c:foo ( / ss1 count)
  (setq ss1   (ssget "X" '((7 . "LLC")))
count 0
  )
  (repeat (sslength ss1)
    (entmod
      (subst '(7 . "LLC1")
     (assoc 7 (setq ent (entget (ssname ss1 count))))
     ent
      )
    )
    (setq count (+ count 1))
  )
)

of course, if you have text in a block, like your title block, the lisp gets more complex, or you can explode your blocks with text in them, foo them, and redefine the block(s).

hope this helps.

roy



Title: Re: Change font type
Post by: ronjonp on September 02, 2009, 10:41:05 PM
Maybe this will help: http://www.theswamp.org/index.php?topic=15317.msg186284#msg186284
Title: Re: Change font type
Post by: alanjt on September 02, 2009, 11:12:56 PM
if all you need to do is change the font for the specific text style, this will work:
Code: [Select]
(vl-catch-all-apply
  '(lambda ()
     (vla-put-fontfile
       (vla-item
         (vla-get-textstyles
           (vla-get-activedocument
             (vlax-get-acad-object)
           ) ;_ vla-get-activedocument
         ) ;_ vla-get-textstyles
         "LCC"
       ) ;_ vla-item
       "Arial.ttf"
     ) ;_ vla-put-fontfile
   ) ;_ lambda
) ;_ vl-catch-all-apply
Title: Re: Change font type
Post by: Joe Burke on September 03, 2009, 06:51:33 AM
Also keep in mind, if mtext contains embedded font formatting, changing the text style will not change the appearance of the text. You would have to remove the embedded format codes from the text string.
Title: Re: Change font type
Post by: alanjt on September 03, 2009, 09:01:07 AM
Also keep in mind, if mtext contains embedded font formatting, changing the text style will not change the appearance of the text. You would have to remove the embedded format codes from the text string.
tag, you're it.
Title: Re: Change font type
Post by: Joe Burke on September 04, 2009, 08:24:38 AM
Okay,

Attached is my current beta version of StripFormat.

Example: strip only embedded font formatting from an mtext string:

(StripFormat <string> (list "F"))

BTW, "your" is a possessive pronoun. The correct syntax is "you're". A contraction of "you are".
Title: Re: Change font type
Post by: alanjt on September 04, 2009, 09:39:05 AM
Okay,

Attached is my current beta version of StripFormat.

Example: strip only embedded font formatting from an mtext string:

(StripFormat <string> (list "F"))

BTW, "your" is a possessive pronoun. The correct syntax is "you're". A contraction of "you are".
you're absolutely correct. fast typing and not thinking about what i was saying, but is that really relevant?
Title: Re: Change font type
Post by: Joe Burke on September 04, 2009, 09:58:04 AM
Okay,

Attached is my current beta version of StripFormat.

Example: strip only embedded font formatting from an mtext string:

(StripFormat <string> (list "F"))

BTW, "your" is a possessive pronoun. The correct syntax is "you're". A contraction of "you are".
you're absolutely correct. fast typing and not thinking about what i was saying, but is that really relevant?

From my viewpoint, it's relevant if you want me to pay attention to your comments. Bad English tends to be ignored.

Let's try to refocus on the issues at hand.
Title: Re: Change font type
Post by: alanjt on September 04, 2009, 10:53:15 AM
Okay,

Attached is my current beta version of StripFormat.

Example: strip only embedded font formatting from an mtext string:

(StripFormat <string> (list "F"))

BTW, "your" is a possessive pronoun. The correct syntax is "you're". A contraction of "you are".
you're absolutely correct. fast typing and not thinking about what i was saying, but is that really relevant?

From my viewpoint, it's relevant if you want me to pay attention to your comments. Bad English tends to be ignored.

Let's try to refocus on the issues at hand.
my sentiments exactly.
Title: Re: Change font type
Post by: T.Willey on September 04, 2009, 11:05:40 AM
If you set it up correctly, then you can use the code here ( link below ) to run through drawings without opening them in the editor.

[ http://www.theswamp.org/index.php?topic=29933.0 ]
Title: Re: Change font type
Post by: alanjt on September 04, 2009, 11:23:05 AM
If you set it up correctly, then you can use the code here ( link below ) to run through drawings without opening them in the editor.

[ http://www.theswamp.org/index.php?topic=29933.0 ]
great idea Tim.