Jump to content

Need LISP to change global text font


Vigilante

Recommended Posts

Hi all, I've searched google and this forum and not found much. Some help would be appreciated.

 

Basically, we get documents from other people and we convert those to our formats to do our work.

We use a font called Simplex, but sometimes their document is filled with, like, Comic Sans or something stupid.

The match properties command doesn't seem to change font, just size and alignment.

When I use the font properties dialog box, I can set simplex as the font, but when I make new text, it still matches their comic sans. It's kinda weird.

 

So two questions:

How do I change the default font for the document so that all new text is the way I want it?

 

And is there a LISP routine which will find all text and change the font property and stuff the way I want it? For multi-line and single line text.

 

Also note, I've tried selecting all the text and editing properties, but font is not one of the properties I can change. To change font, I have to edit every piece of text one by one. And then ONLY multiline text has the properties to change font. So frankly I don't even know how to change the font of a single line text object.

 

Any help for me? Thanks a bunch.

Link to comment
Share on other sites

So frankly I don't even know how to change the font of a single line text object.

 

Any help for me? Thanks a bunch.

 

Use the STYLE command and change the font of the text style that the single text object is using. Once you change the style, all single line text objects using that style will update globally.

Link to comment
Share on other sites

Hey cool, that's what I needed.

 

The only thing is, when in the style dialog, it has like a drop down for "style name", and the document has like 7 or 8 or more styles. So I have to click each style, change the font, next, next etc...

 

So then, it would be cool to place all text objects in one style name, delete the rest, and then I can change just that one style.

So then, is there a lisp to place all text in one style and remove the others?

Just asking.

 

Thanks again.

Link to comment
Share on other sites

Vigilante,

 

I've been meaning to write something that will do this for some time and your question has prompted me to do it. It hasn't been tested a lot, but seems to work (and I wasn't sure how to select all text and all mtext in the one hit, so I cheated and ran the routine twice...). It changes all text to isocp.shx, but you could change that to whatever font you need.

 

(defun C:CHANGESTYLE (/ entities len count ent ent_data ent_name new_style_name)

(command "STYLE" "iso" "isocp.shx" "" "" "" "" "")
(setq entities (ssget "X" '((0 . "TEXT")))
     len      (sslength entities)
     count 0
);setq 

(while (< count len)
      (setq ent      (ssname entities count) 
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while

;;;runs same routine again, picking up Mtext this time.

(setq entities (ssget "X" '((0 . "MTEXT")))
     len      (sslength entities)
     count 0
);setq 

(while (< count len)
      (setq ent      (ssname entities count) 
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while

(princ)

);defun

Edited by SLW210
Add TAGS!
Link to comment
Share on other sites

Wozza,

 

Some some selection filter tips to help keep your routines shorter...

 

The selection filter allows using multiple data by combining with commas, and use of wildcards. So you could use either of the following to select text & mtext:

 

 

(setq entities (ssget "X" '((0 . "TEXT,MTEXT")))

-or-

(setq entities (ssget "X" '((0 . "*TEXT")))

Edited by SLW210
Link to comment
Share on other sites

Carl,

 

Thanks for that. With all the places available to look for info on this I couldn't find anything that explained 'select all this type of entity AND this type of entity'.

 

Incidently, it seems that some Mtext will not change the way it looks (using the above routine) until it's been exploded. Exploding the text doesn't cause any problems for us, so I included this line just after the last (entmod ent_data)

 

(command "explode" ent)

 

Seems to work OK.

Link to comment
Share on other sites

  • 5 years later...
Use the STYLE command and change the font of the text style that the single text object is using. Once you change the style, all single line text objects using that style will update globally.

Thanks for the helpful information.

Link to comment
Share on other sites

Vigilante,

 

I've been meaning to write something that will do this for some time and your question has prompted me to do it. It hasn't been tested a lot, but seems to work (and I wasn't sure how to select all text and all mtext in the one hit, so I cheated and ran the routine twice...). It changes all text to isocp.shx, but you could change that to whatever font you need.

 

(defun C:CHANGESTYLE (/ entities len count ent ent_data ent_name new_style_name)

(command "STYLE" "iso" "isocp.shx" "" "" "" "" "")
(setq entities (ssget "X" '((0 . "TEXT")))
     len      (sslength entities)
     count 0
);setq 

(while (< count len)
      (setq ent      (ssname entities count) 
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while

;;;runs same routine again, picking up Mtext this time.

(setq entities (ssget "X" '((0 . "MTEXT")))
     len      (sslength entities)
     count 0
);setq 

(while (< count len)
      (setq ent      (ssname entities count) 
            ent_data (entget ent)
            ent_name (cdr (assoc 7 ent_data))
      );setq

(setq new_style_name (cons 7 "iso"))
(setq ent_data (subst new_style_name (assoc 7 ent_data) ent_data))
(entmod ent_data)

(setq count (+ count 1))
);while

(princ)

);defun

 

 

You said that this will change all text to a certain font. Will it change the text within to a certain Text Style. I came across this thread and I'm trying to find a lisp that will change all text in drawings to a single style, namely the style Standard. An I'm also looking to globally change all the dims to a certain dim style as well, namely the style Standard. I'm guessing here but will a script work as well?

 

I'm also working in AutoCAD Architecture 2012.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...