tmelancon Posted May 9, 2019 Share Posted May 9, 2019 BRILLIANT code by Lee Mac helping another user out on the webs... Thank you Lee for your years of dedication to the AutoCAD/Code world! (defun changeattributewidth ( tag wid / typ ) (setq tag (strcase tag)) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= :vlax-false (vla-get-isxref blk)) (vlax-for obj blk (cond ( (= "AcDbBlockReference" (setq typ (vla-get-objectname obj))) (foreach att (vlax-invoke obj 'getattributes) (if (and (= tag (strcase (vla-get-tagstring att))) (vlax-write-enabled-p att)) (vla-put-scalefactor att wid) ) ) ) ( (and (= "AcDbAttributeDefinition" typ) (= tag (vla-get-tagstring obj)) (vlax-write-enabled-p obj) ) (vla-put-scalefactor obj wid) ) ) ) ) ) (princ) ) (vl-load-com) (princ) Evaluate with tag name (case-insensitive) and new attribute width factor, e.g.: (changeattributewidth "tag" 0.7) I was just curious to see if there was a way to edit the code so upon command and selection of block it allows user to dynamically scale the attribute (just like running the regular scale command on any other text).. this way if the text within a titleblock is too long and the user is unsure of exactly how much shorter it needs to be then he/she can just quickly run shortcut command, click on block/attribute, automatically step into block, select attribute, and the user can drag mouse to scale up or down dynamically. Any and all help is so so much appreciate. Blessings. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 9, 2019 Share Posted May 9, 2019 @tmelancon Thank you for your praise & gratitude for my work. In response to your request, have you first considered my existing Dynamic Attribute Width program? Quote Link to comment Share on other sites More sharing options...
tmelancon Posted May 9, 2019 Author Share Posted May 9, 2019 Oh such a beautiful program! I apologize for not even looking on your site first. Forgive me. Would it be possible to mod it for both height and width? Killer LISP! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 9, 2019 Share Posted May 9, 2019 Thanks - I'm glad you like it. Modifying the program for both height & width is not quite as straightforward, as, whilst the width factor can scale the width independently of the height, changing the height also impacts the width. Quote Link to comment Share on other sites More sharing options...
tmelancon Posted May 10, 2019 Author Share Posted May 10, 2019 Lee, I hope you don't mind. I changed the DXF code "41" to "40" throughout and this is exactly what I needed. BOOM! Thanks man! LISP is for personal use and of course the modified version will not be shared. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 10, 2019 Share Posted May 10, 2019 Not at all - I thought you were looking to change the height independently of the width, but if that works as you require, that's great Quote Link to comment Share on other sites More sharing options...
tmelancon Posted May 10, 2019 Author Share Posted May 10, 2019 (edited) What would be awesome is if this code could be modded to where when the user steps in and selects the attribute text, dragging the cursor freely, up and down changes the height and side to side changes the width. Ultimately making the text precisely what you want it to look like and fit in to whatever space you wanted regardless of how it looked. Edited May 10, 2019 by tmelancon Quote Link to comment Share on other sites More sharing options...
tmelancon Posted May 10, 2019 Author Share Posted May 10, 2019 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.