Hi,
I'm new to writing scripts and I'm a bit lost.
I'm trying to write a lisproutine that would open all dwgs in a folder, and change the textstyle of all attributes in each file.
My problem is that for the selection of attributes the ATTEDIT command
"Expects a point or Window/Last/Crossing/BOX/Fence/WPolygon/CPolygon/Previous/AUto"
Whereas I would rather have something along the lines of
"_ai_selall"
Would there be an easy way to "simulate/script" a crossing or window selection without actually having to point and click for each .dwg in the batch?
Or is it possible to play around with one of the other selectiontypes (I'm not familiar with all of the options given) into selecting all attributes in a drawing?
Alternatively, another idea I was playing around with was to set the font of all existing text-styles, but that was another dead end since I couldn't find a way to read which custom text-styles exist in a .dwg
I imagine something like that would also need to count how many custom styles exist, and setting a number of variable to those style-names and such. But if that's the only way...
Thx
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Welcome to the Autodesk Discussion Groups, Steven!
Just as a "demo"...
(defun c:demo ( / attlst hnd i NewStyle obj ss styles stylst) (vl-load-com) (if (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1)))) (progn (setq styles (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for sty styles (setq stylst (cons (vla-get-name sty) stylst)) ) (if (not (member "MyStyleName" stylst)) (progn (setq NewStyle (vla-add styles "MyStyleName")) (vla-put-fontFile NewStyle "C:/WINDOWS/Fonts/arial.ttf") ) );; if (repeat (setq i (sslength ss)) (setq hnd (ssname ss (setq i (1- i))) attlst nil obj (vlax-ename->vla-object hnd) attlst (vlax-invoke obj 'GetAttributes) );; setq (foreach att attlst (if (vlax-write-enabled-p att) (vla-put-StyleName att "MyStyleName") );; if );; foreach );; repeat );; progn );; if (princ) );; demo
For the batch, try the Lee Mac's Script Writer.
HTH
Henrique
Oh my, here I was just expecting a push in the right direction and you've gonne and completely solved the problem for me.
I had some trail and error with that script writer but in the end I got that to work to.
Lots of thanks 😄
What if I wanted to change ALL text styles, text, mtext, dimstyle fonts, etc...?
That would be greatly appreciated. Thanks!
Henrique,
I would really like to be able to change font style of Arch and Simple to Archtxt. Text, Mtext, dimensions, attributes in blocks. On a wide scale.
Please help (if possible)! Thanks!
@m_rogoff wrote:
I would really like to be able to change font style of Arch and Simple to Archtxt. Text, Mtext, dimensions, attributes in blocks. On a wide scale.
Hi m_rogoff,
to change the font style, you can replace the font file with something like this
(setq styles (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for sty styles (if (wcmatch (strcase (vla-get-fontFile sty)) "ARCH.SHX,SIMPLE.SHX") (vla-put-fontFile sty "C:/WINDOWS/Fonts/Archtxt.shx");; change to correct font path ) )
with mtext, if the text string don't have formatting, should work...
You'll need to add a "regen" or a "regenall" to see the changes.
HTH
Henrique