Jump to content

need an emergency lisp changes all text styles to one


blackeagle1245

Recommended Posts

hey guys

I need an emergency lisp that changes all font's to a one font. For example there are 10 different text styles in a dwg but I want all of them in Romans.

 

Thanks in advance.

Link to comment
Share on other sites

thanks for quick reply. I found this but how can I make it to change all of them to romandtw some fontstyles stay the same I think they stay out of range.

 

(vl-load-com)

(defun c:updateTextstyles (/ new)
(setq new (strcat (getenv "systemroot") "[url="file://\\Fonts\\romandtw.shx"]\\Fonts\\romandtw.shx[/url]"))
(vlax-map-collection
(vla-get-textstyles
(vla-get-activedocument
(vlax-get-acad-object)))
'(lambda (x / font)
(setq font (strcase (vla-get-fontfile x)))
(if (wcmatch font "ROMANS.SHX,SIMPLEX.SHX,TXT.SHX")
(vla-put-fontfile x new)))
)
(princ)
)

Edited by SLW210
Place code in tags!!!
Link to comment
Share on other sites

My first try in changing the Font Test Styles ... :)

 

(defun c:Test nil
 (vl-load-com)
 ;; Tharwat 04. 07. 2011
 (vlax-for x (vla-get-textstyles
               (vla-get-activedocument (vlax-get-acad-object))
             )
   (if (not (eq (vla-get-fontfile x) "romans.shx"))
     (vlax-put-property x 'fontfile "romans.shx")
   )
 )
 (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object))
            acAllViewports
 )
 (princ)
)

 

Tharwat

Link to comment
Share on other sites

can we also add a line that changes width factor to 0.7 ?:oops:

 

(defun c:ChangeWidth nil
 (vl-load-com)
 ;; Tharwat 05. 07. 2011
 (vlax-for x (vla-get-textstyles
               (vla-get-activedocument (vlax-get-acad-object))
             )
   (if (not (eq (vla-get-width x) 0.7))
     (vlax-put-property x 'width 0.7)
   )
 )
 (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object))
            acAllViewports
 )
 (princ)
)

 

Enjoy it buddy. :)

 

Tharwat

Link to comment
Share on other sites

(defun c:ChangeWidth nil
(vl-load-com)
;; Tharwat 05. 07. 2011
(vlax-for x (vla-get-textstyles
(vla-get-activedocument (vlax-get-acad-object))
)
(if (not (eq (vla-get-width x) 0.7))
(vlax-put-property x 'width 0.7)
)
)
(vla-regen (vla-get-ActiveDocument (vlax-get-acad-object))
acAllViewports
)
(princ)
)

 

Enjoy it buddy. :)

 

Tharwat

 

Dear Sir,

one problem i want few text .7 & few text .9

Link to comment
Share on other sites

  • 2 weeks later...
(defun C:TW ()
(setq p (SSGET "X" '((0 . "TEXT")(8 . "TEXT STYLE NAME"))))  ;CHANGE "TEXT STYLE NAME" TO YOUR TEXT STYLE THAT YOU WANT AT 0.7 WIDTH
(setq nwidth 0.7)                                     ;sets widths equal to 0.7
(if (/= p nil)
(progn
(setq l 0
n (sslength p))
(while (< l n)
(setq e (entget (ssname p l)))
(entmod (setq e(subst (cons 41 nwidth) (assoc 41 e) e))
)
(setq l (1+ l))))
)

;REPEATED FROM ABOVE FOR 0.9 WIDTH
(setq p (SSGET "X" '((0 . "TEXT")(8 . "TEXT STYLE NAME"))))  ;CHANGE  "TEXT STYLE NAME" TO YOUR TEXT STYLE THAT YOU WANT AT 0.9 WIDTH
(setq nwidth 0.9)                                     ;sets widths equal to 0.9
(if (/= p nil)
(progn
(setq l 0
n (sslength p))
(while (< l n)
(setq e (entget (ssname p l)))
(entmod (setq e(subst (cons 41 nwidth) (assoc 41 e) e))
)
(setq l (1+ l))))
)
(princ)
)

Edited by fab30
Link to comment
Share on other sites

fab , Welcome to the forum .

 

Try to get used to localize you variables to avoid any mistakes and odd reaction form the routine , And please use

the

 codes here 

to wrap codes for good reading and looking .

 

Tharwat

Link to comment
Share on other sites

@Fab30 - I'm pretty sure that this:

 

...
 (setq p (SSGET "X" '((0 . "TEXT")([color=red]8[/color] . "TEXT STYLE NAME"))))
...

 

... Should be this:

 

(setq p (SSGET "X" '((0 . "TEXT")([color=red]7[/color] . "TEXT STYLE NAME"))))

 

DXF code 8 is the object's Layer name, whereas DXF code 7 is the Text style name.

Link to comment
Share on other sites

  • 3 months later...

Hi, Tharwat

Do you know why your routine does not work with true type fonts?

 

i am trying this

 

(defun c:cgts6 nil
 (vl-load-com)
 ;; Tharwat 04. 07. 2011
 (vlax-for x 
(vla-get-textstyles
               
(vla-get-activedocument 
(vlax-get-acad-object))
             
)
   (if (eq (vla-get-fontfile x) 
"simplex.shx")
     (vlax-put-property x 'fontfile 
"arialn.ttf")
   )
 )
 (vla-regen 
(vla-get-ActiveDocument 
(vlax-get-acad-object))
            
acAllViewports
 )
 (princ)
)

 

But it simply doesn´t recognize the arialn.ttf

My first try in changing the Font Test Styles ... :)

 

(defun c:Test nil
 (vl-load-com)
 ;; Tharwat 04. 07. 2011
 (vlax-for x (vla-get-textstyles
               (vla-get-activedocument (vlax-get-acad-object))
             )
   (if (not (eq (vla-get-fontfile x) "romans.shx"))
     (vlax-put-property x 'fontfile "romans.shx")
   )
 )
 (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object))
            acAllViewports
 )
 (princ)
)

 

Tharwat

Link to comment
Share on other sites

Hi, Tharwat

Do you know why your routine does not work with true type fonts?

..
   (if (eq (vla-get-fontfile x) 
"simplex.shx")
     (vlax-put-property x 'fontfile 
"arial[color=blue][b]n[/b][/color].ttf") [color=red][b];; Should be arial.ttf[/b][/color]
   )
 )

But it simply doesn´t recognize the arialn.ttf

 

Your question seems you're challenging me .

Link to comment
Share on other sites

At all... I didn´t mean to attack you.

 

it's just that I tried the arialn.ttf and you know... It's my fault... arialn.ttf is the Arial Narrow font, it's part of Arial font family, but I didn´t check that it is actually in a separated file arialn.ttf which was not included in my Fonts support folder, now I downloaded it and placed it in my support folder and your routine worked perfectly.

 

Now I got another problem with the same width matter, but it seems more difficult or impossible... thanks for your response.

 

 

 

Your question seems you're challenging me .
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...