Jump to content

AutoCAD Lisp Routine to change all attributes / text to a style


Recommended Posts

Posted
thanx Grrr. In the end (or should I say begin) the problem was the difference between vla-get-block or vla-get-blocks... one stupid letter...

 

Doh, even I didn't saw it.. maybe next time before implementing the mapping routine into odbx, to test it first on the active dwg (for easier error-tracing).

 

 

 

Yeah , my void only goes so many levels deep in an empty string that was because I wrote it before vlisp existed and before vl-string->list / -trim etc existed. And still it has served me well all the these years , pure nostalgia

 

:D

 

Ah, I see... altho I liked that subfoo, so I use it /a rewritten version/ in some of my DCL routines (to check for a valid edit_box input).

Still solvable without vl-* :

; _$ (mapcar 'valid-p (list nil "" " " "  " 123 "str" "                            ")) >> (nil nil nil nil 123 T nil)
(defun valid-p ( s / c )
 (cond 
   ( (not (eq 'STR (type s))) s)
   ( (= s "") nil)
   ( (/= (setq c (substr s 1 1)) " ") t)
   ( (valid-p (substr s 2)) )
 )
); defun valid-p

 

:P

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • rlx

    11

  • Grrr

    7

  • Lawrst

    2

  • StevJ

    1

Top Posters In This Topic

Posted
Ah, I see... altho I liked that subfoo, so I use it /a rewritten version/ in some of my DCL routines (to check for a valid edit_box input). :P

 

I realy like my 'tiny-lisp' functions , one-liners etc. but... only if they're stable else my code must read like a good book so I can understand what I meant a year later. I also like to put as much information on one line in my vlisp editor so I use 140 character lines in my code. It's a disaster when printing but I rarely print anyway and that way I can have allmost double the code in my window then when I would limit my lines to lets say 80 characters. And if anyone has a problem with that , just use format code in the vlisp editor. Only downside of my 'tiny-lisp'functions is that now and again I forget to include them when I post a code on a thread because they are spread out over all my lisp routines so if one routine hasn't got them I will always have another function that loads it. Well... it has been a long day so....

 

:sleeping:

  • 2 months later...
Posted

This is a great code. Can you add one more option to change width factor of texts to 1.

Posted
This is a great code. Can you add one more option to change width factor of texts to 1.

 

 

not tested (no time) but replace the following section :

 

 



(defun change_text_style  ( $dwg / odbxdoc acstyles style-obj fnt layout obj o-name bn bn-list ent)
 (if (and (setq odbxdoc (odbx_open $dwg)) (setq acstyles (vla-get-textstyles odbxdoc))
   (setq style-obj (vla-add acstyles "Company_Name")) (setq fnt (findfile "C:\\Windows\\Fonts\\arialn.ttf")))
   (progn
     (vla-put-fontfile style-obj fnt)
     (vlax-for layout (vla-get-layouts odbxdoc)
       (vlax-for obj (vla-get-block layout)
         (cond
           ; remove "AcDbText" "AcDbMText" to NOT update (m)text's
           ((member (vla-get-objectname obj) '("AcDbText" "AcDbMText" "AcDbAttributeDefinition"))
            (vla-put-StyleName obj "Company_Name"))
           ((= (vla-get-objectname obj) "AcDbBlockReference")
            (mapcar 
                 '(lambda(x) 
                      (vla-put-StyleName x "Company_Name")
                      [color=red](vla-put-ScaleFactor x <put your width here>)[/color]
                 ) 
            (get-block-ent obj)))
         )
       )
     )
     (vl-catch-all-error-p (vl-catch-all-apply 'vla-saveas (list odbxdoc $dwg)))
   )
 )
)

 

 

have to start with my new project now , so I'll check later...

 

 

gr. Rlx

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...