Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert All Text Except "Helv" To "Standard" Question

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
224 Views, 3 Replies

Convert All Text Except "Helv" To "Standard" Question

Good Morning Everyone,

Below I've posted a great routine by Jeff Mishler that converts all text in a file to "Standard". I've used it many times and it works great but I do have a question regarding how it might be modified to convert All text EXCEPT for Helv.

My thinking is to add a not equal to paren grouping to the Wcmatch "TEXT" line, but have yet to get it to successfully work.

Any help in the right direction would be much appreciated.

Thanks
Coyote

;;Change all text, mtext, dimension text, attribute text to the
;;"STANDARD" text style. Preserves all existing text heights &
;;obliquing angles.
;; by Jeff Mishler
(defun c:txt2std (/ styl ss ent count doc blks lokt)
(vl-load-com)
(vla-startundomark (setq doc (vla-get-activedocument
(vlax-get-acad-object)
)))
(vlax-for lay (vla-get-layers doc)
(if (= (vla-get-lock lay) :vlax-true)
(progn
(setq lokt (cons lay lokt))
(vla-put-lock lay :vlax-false)
)
)
)
(if (not (tblsearch "style" "STANDARD"))
(progn
(setq styl (vla-add
(vla-get-textstyles doc)
"STANDARD")
)
(vla-put-fontfile styl "txt.shx")
)
)
(if (setq ss (ssget "x" '((0 . "*TEXT,*DIM*,INSERT"))))
(progn
(setq count -1)
(while (< (setq count (1+ count)) (sslength ss))
(setq ent (vlax-ename->vla-object (ssname ss count)))
(cond ((wcmatch (strcase (vla-get-objectname ent)) "*TEXT*")
(vla-put-stylename ent "STANDARD"))
((wcmatch (strcase (vla-get-objectname ent)) "*BLOCK*")
(progn
(if (= (vla-get-hasattributes ent) :vlax-true)
(progn
(setq atts (vlax-safearray->list
(vlax-variant-value
(vla-getattributes ent))))
(foreach x atts
(vla-put-stylename x "STANDARD")
)
)
)
)
)
(t (vla-put-textstyle ent "STANDARD"))
)
)
)
)
(if (< 0 (vla-get-count (setq blks (vla-get-blocks doc))))
(progn
(vlax-for blk blks
(vlax-for ent blk
(if (vlax-property-available-p ent 'stylename)
(vla-put-stylename ent "STANDARD")
)
)
)
)
)
(if lokt
(progn
(foreach lay lokt
(vla-put-lock lay :vlax-true)
)
)
)
(vla-endundomark doc)
(princ)
)
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

(Untested)..
;;Change all text, mtext, dimension text, attribute text to the
;;"STANDARD" text style. Preserves all existing text heights &
;;obliquing angles.
;; by Jeff Mishler

;; Modified by Bob Shaw, not to do 'Helv'

(defun c:txt2std (/ styl ss ent count doc blks lokt)
(vl-load-com)
(vla-startundomark (setq doc (vla-get-activedocument
(vlax-get-acad-object)
)))
(vlax-for lay (vla-get-layers doc)
(if (= (vla-get-lock lay) :vlax-true)
(progn
(setq lokt (cons lay lokt))
(vla-put-lock lay :vlax-false)
)
)
)
(if (not (tblsearch "style" "STANDARD"))
(progn
(setq styl (vla-add
(vla-get-textstyles doc)
"STANDARD")
)
(vla-put-fontfile styl "txt.shx")
)
)
(if (setq ss (ssget "x" '((0 . "*TEXT,*DIM*,INSERT"))))
(progn
(setq count -1)
(while (< (setq count (1+ count)) (sslength ss))
(setq ent (vlax-ename->vla-object (ssname ss count)))
(cond
((wcmatch (strcase (vla-get-objectname ent)) "*TEXT*")
(setq pres_style (strcase (vla-get-stylename ent)))
(if (/= pres_style "HELV")
(vla-put-stylename ent "STANDARD")
); if
)
((wcmatch (strcase (vla-get-objectname ent)) "*BLOCK*")
(progn
(if (= (vla-get-hasattributes ent) :vlax-true)
(progn
(setq atts (vlax-safearray->list
(vlax-variant-value
(vla-getattributes ent))))
(foreach x atts
(setq pres_style (strcase (vla-get-stylename x)))
(if (/= pres_style "HELV")
(vla-put-stylename x "STANDARD")
); if
)
)
)
)
)
(t
(setq pres_style (strcase (vla-get-stylename ent)))
(if (/= pres_style "HELV")
(vla-put-stylename ent "STANDARD")
); if
)
)
)
)
)
(if (< 0 (vla-get-count (setq blks (vla-get-blocks doc))))
(progn
(vlax-for blk blks
(vlax-for ent blk
(if (vlax-property-available-p ent 'stylename)
(progn
(setq pres_style (strcase (vla-get-stylename ent)))
(if (/= pres_style "HELV")
(vla-put-stylename ent "STANDARD")
); if
); progn
)
)
)
)
)
(if lokt
(progn
(foreach lay lokt
(vla-put-lock lay :vlax-true)
)
)
)
(vla-endundomark doc)
(princ)
)

Bob
Message 3 of 4
Anonymous
in reply to: Anonymous

Bob,

It worked perfectly.

Thanks once again for your help.
Coyote
Message 4 of 4
Anonymous
in reply to: Anonymous

You are Welcome.
And, thanks to Jeff 😉

Bob

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost