PDA

View Full Version : Global Change all Text Styles to Romans font



f.tagle
2006-07-20, 01:51 AM
I need a LISP routine that would Globally Change all Text Styles to Romans font without
any dialog box popping out.

Thank you very much for your help.

rkmcswain
2006-07-20, 03:19 AM
This should help.

http://www.theswamp.org/index.php?topic=6343.0

Buffeldrek
2006-07-20, 06:13 AM
quick select all text -> change text style Roman ???

rkmcswain
2006-07-20, 09:34 AM
quick select all text -> change text style Roman ???

That changes the 'style' of each text entity. The request was to change the 'font' for each 'textstyle' in the drawing. Two different things.

Adesu
2006-07-21, 02:07 AM
I need a LISP routine that would Globally Change all Text Styles to Romans font without
any dialog box popping out.

Thank you very much for your help.

Hi f.tagle,
I have a program to change alls text style in your drawing area to specific text style,here my code


; cgts is stand for Change Global all Text Styles
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 21 July 2006
; Program no.: 0386/07/2006
; Edit by
(defun c:cgts (/ cnt ed fla hjus hjust oang opt rot sfac sp ss
sse ssl ssn str sty th vjus vjust)
(setq opt (getstring "\nEnter text style name <Standard>: "))
(if (= opt "")(setq opt "Standard"))
(if
(setq ss (ssget "x" '((0 . "TEXT"))))
(progn
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(setq sse (entget ssn))
(setq lay (cdr (assoc 8 sse)))
(setq sp (cdr (assoc 10 sse)))
(setq th (cdr (assoc 40 sse)))
(setq str (cdr (assoc 1 sse)))
(setq rot (cdr (assoc 50 sse)))
(setq sfac (cdr (assoc 41 sse)))
(setq oang (cdr (assoc 51 sse)))
(setq sty (cdr (assoc 7 sse)))
(setq fla (cdr (assoc 71 sse)))
(setq hjust (cdr (assoc 72 sse)))
(setq vjust (cdr (assoc 73 sse)))
(command "_erase" ssn "")
(entmake (list '(0 . "TEXT")
(cons 8 lay) ; current layer
(cons 10 sp) ; start point
(cons 40 th) ; text height
(cons 1 str) ; name of text
(cons 50 rot) ; text rotation
(cons 41 sfac) ; with factor
(cons 51 oang) ; oblique angle
(cons 7 opt) ; text style name
(cons 71 fla) ; 2 = backward,4 = upside down
;(cons 72 hjus) ; horizontal justification
;(cons 73 vjus) ; vertical justification
))
(setq cnt (1+ cnt))
) ; repeat
) ; progn
(alert "\nThere is not text in your drawing area")
) ; if
(princ)
)

rkmcswain
2006-07-21, 02:24 AM
You guys must know somethat that I don't..... :)

That routine does not do what the OP asks - unless I am reading it wrong...

Of course, now that I actually read the code in the link I posted - i see it does the same thing.

OK, f.tagle - if you really want to change the font in each textstyle to Romans - here you go...



(vl-load-com)
(vlax-for x (vla-get-textstyles
(vla-get-activedocument (vlax-get-acad-object))
)
(vla-put-fontfile x "Romans.shx")
)




BTW Adesu, you don't need to grab all the properties, delete the entity, then create a new one You can simply use (subst) to replace the changed properties, then use (entmod) to modify the entity.

Adesu
2006-07-25, 06:24 AM
Hi rkmcswain,
Thanks for your correction.


BTW Adesu, you don't need to grab all the properties, delete the entity, then create a new one You can simply use (subst) to replace the changed properties, then use (entmod) to modify the entity.

brendan.upton
2009-03-04, 01:39 AM
I know this thread is a couple of years old but i had a question regarding Adesu's Lisp. It works great and is exactly what i was after, but is there a way to change it slightly so that it changes to a specified text style rather than ask the user to enter the name of the text style.

I understand that some users want to be able to put in any number of text styles depending on the circumstance but i would like to change the text style to ISOCP every single time without exception.

Cheers for any help,
Regards, Brendan

rkmcswain
2009-03-04, 01:50 AM
This should work



;;;replace this
(setq opt (getstring "\nEnter text style name <Standard>: "))
(if (= opt "")(setq opt "Standard"))

;;;with this

(setq opt "ISOCP")

brendan.upton
2009-03-04, 02:06 AM
WOW thanks R.K., that was quick.
It works perfectly now!

Cheers,
Brendan

brendan.upton
2009-03-04, 03:59 AM
Hi again R.K.

I've noticed that this LISP only deals with text if i wanted to change Mtext with the same routine would it be as simple as altering or adding the line

(setq ss (ssget "x" '((0 . "TEXT"))))

to say Mtext??

Are there any tricks/traps with this?

Many thanks again for any help

rkmcswain
2009-03-04, 04:05 AM
You could replace "TEXT" with "TEXT,MTEXT".
Not sure of the effect on this routine, but it should work as long as DXf 7 is the style name for MTEXT.

irneb
2009-03-04, 05:24 AM
Generally the "TEXT,MTEXT" filter as rkmcswain's shown should do the trick. Unfortunately MTEXT has a further possible problem: due to its internal formatting the user may have changed the text style (or rather font) to something else. So even through the MTEXT is set to ISCOCP it may be displaying Arial.:roll:

I think I remember a thread regarding removing these also from MTEXT ... doing a quick search through this forum:

http://forums.augi.com/showthread.php?t=53441&highlight=mtext+remove+formatting

brendan.upton
2009-03-04, 11:41 PM
You could replace "TEXT" with "TEXT,MTEXT".
Not sure of the effect on this routine, but it should work as long as DXf 7 is the style name for MTEXT.

I just tried this but when i ran a test, it changed the text fine but it actually deleted the mtext instead of changing it.

Any thoughts as to why it would delete it?

irneb
2009-03-05, 04:47 AM
That's because ADesu's code is getting the particulars from the MText, Erasing the MText, then creating a TEXT with the same values. Rkmcswain's suggested rather using subst and entmod, i.e. modify the entity instead of recreating it. That way you only have to work with the values that actually changes, also stuff like draworder is not messed up. Here's the code as it should be in this case, additions in green, omittions in gray:
; cgts is stand for Change Global all Text Styles
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 21 July 2006
; Program no.: 0386/07/2006
; Edit by : Irné Barnard 2009-03-05
(defun c:cgts (/ cnt ed fla hjus hjust oang opt rot sfac sp ss sse ssl ssn str sty th vjus vjust)
;;; Removed as suggested
;;; (setq opt (getstring "\nEnter text style name <Standard>: "))
;;; (if (= opt "")
;;; (setq opt "Standard")
;;; ) ;_ end of if
;; Replaced with
(setq opt "ISOCP")
(if
(setq ss (ssget "x" '((0 . "TEXT,MTEXT")))) ;Added MTEXT filter as well
(progn
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(setq sse (entget ssn))
(setq sse (subst (cons 7 opt) (assoc 7 sse) sse)) ;Added substitute Text Style in DXF codes list
(entmod sse) ;Added modify the entity instead of delete & recreate
;;; Remove this as it's not needed
;;; (setq lay (cdr (assoc 8 sse)))
;;; (setq sp (cdr (assoc 10 sse)))
;;; (setq th (cdr (assoc 40 sse)))
;;; (setq str (cdr (assoc 1 sse)))
;;; (setq rot (cdr (assoc 50 sse)))
;;; (setq sfac (cdr (assoc 41 sse)))
;;; (setq oang (cdr (assoc 51 sse)))
;;; (setq sty (cdr (assoc 7 sse)))
;;; (setq fla (cdr (assoc 71 sse)))
;;; (setq hjust (cdr (assoc 72 sse)))
;;; (setq vjust (cdr (assoc 73 sse)))
;;; (command "_erase" ssn "")
;;; (entmake (list '(0 . "TEXT")
;;; (cons 8 lay) ; current layer
;;; (cons 10 sp) ; start point
;;; (cons 40 th) ; text height
;;; (cons 1 str) ; name of text
;;; (cons 50 rot) ; text rotation
;;; (cons 41 sfac) ; with factor
;;; (cons 51 oang) ; oblique angle
;;; (cons 7 opt) ; text style name
;;; (cons 71 fla) ; 2 = backward,4 = upside down
;;; ;(cons 72 hjus) ; horizontal justification
;;; ;(cons 73 vjus) ; vertical justification
;;; ) ;_ end of list
;;; ) ;_ end of entmake

(setq cnt (1+ cnt))
) ; repeat
) ; progn
(alert "\nThere is not text in your drawing area")
) ; if
(princ)
) ;_ end of defun

rkmcswain
2009-03-05, 01:03 PM
That's because ADesu's code is getting the particulars from the MText, Erasing the MText, then creating a TEXT with the same values. Rkmcswain's suggested rather using subst and entmod, i.e. modify the entity instead of recreating it.

Thanks for the update. Unfortunately, I was only addressing the specific question and not looking at the routine as a whole... Good example of why you have to in many cases...

brendan.upton
2009-03-06, 03:35 AM
Thanks a million to you both for your time and patience with a novice, it's much appreciated!!
it's now working exactly how i'd like it. I've just changed the function command to something more memeorable.

Again, thankyou very much

Cheers,Brendan

johnccole
2009-04-28, 07:18 PM
Guys, sorry but I can't get Adesu's routine, revised by RKMcSwain and Irne, to even run. I'm using Arch desktop 2006 on XP.
After calling the routine, I get this error:

Command: cgts2
*Cancel*
no function definition: REPEAT\\PAR

And another thing, (please ;-) I read the earlier suggestion to change all to one, in this case "romans". But couldn't get "fastselect" to do that. Seems I don't have "quickselect" in version 2006. Is there something I'm missing?
Actually what I'm after is changing a series of existing different text styles (not every textstyle in the drawing), to a new style I created.
thanks for any help, as always
jc

here is the code I'm working with:


; cgts is stand for Change Global all Text Styles
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 21 July 2006
; Program no.: 0386/07/2006
; Edit by : Irné Barnard 2009-03-05
(defun c:cgts2 (/ cnt ed fla hjus hjust oang opt rot sfac sp ss sse ssl ssn str sty th vjus vjust)
;;; Removed as suggested
;;; (setq opt (getstring "\nEnter text style name <Standard>: "))
;;; (if (= opt "")
;;; (setq opt "Standard")
;;; ) ;_ end of if
;; Replaced with
(setq opt "romans-ay")
(if
(setq ss (ssget "x" '((0 . "TEXT,MTEXT")))) ;Added MTEXT filter as well
(progn
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(setq sse (entget ssn))
(setq sse (subst (cons 7 opt) (assoc 7 sse) sse)) ;Added substitute Text Style in DXF codes list
(entmod sse) ;Added modify the entity instead of delete & recreate
(setq cnt (1+ cnt))
) ; repeat
) ; progn
(alert "\nThere is not text in your drawing area")
) ; if
(princ)
) ;_ end of defun

irneb
2009-04-29, 05:04 AM
Command: cgts2
*Cancel*
no function definition: REPEAT\\PARSounds like a bad installation ... REPEAT is a normal lisp function, so it should work even in versions prior to 2000. I've come across something similar on one PC here (Vanilla 2008 on XP 32bit): the AUTOLOAD function didn't work. A repair install solved it.


Actually what I'm after is changing a series of existing different text styles (not every textstyle in the drawing), to a new style I created.In that case, I'd suggest looking into Drawing Standards. Save a template file (with all your layers, dimstyles, textstyles, etc. to a DWS file (one of the options in Save As dialog).

Then in the drawing which you need to change, Tools --> CAD Standards --> Configure. Click the PLUS (+) button, browse to the DWS you saved. Then click the "Check Standards ..." button, bottom left. It'll ask you questions about each layer or style not conforming with that in the DWS. You can select "Next" to Ignore, or "Fix" to Replace with that contained in the DWS. You can also check the Mark as Ignore box if you don't want to be asked for this next time you run STANDARDS.

:banghead: Sorry, couldn't check the last part on my AC. When I clicked Check Standards I got a fatal error ... 1st time on this command ... :mrgreen: ... hope it doesn't mean something's broken.