Jamesjh1171 Posted July 13, 2017 Posted July 13, 2017 Hi this one should be simple for someone who knows LISP. All I want to do is to be able to change all the dimstyles in a dwg to 'standard' (and textstyles as well while I'm at it). My problem is when I scale down a dwg from mm into m, the dims and text are left huge and I have to go through deleting or changing their styles. I'd just like to be able to change them all with one click - simples! Ideally it could be put into my acaddoc file, failing that a standalone lisp so I can then make a button to do it. Quote
ronjonp Posted July 13, 2017 Posted July 13, 2017 (edited) Try this: (vl-load-com) (defun c:tostandard nil ;; This code honors locked layers... (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vlax-for b a (if (vlax-property-available-p b 'stylename) (cond ((vlax-property-available-p b 'hasattributes) (foreach x (vlax-invoke b 'getattributes) (vl-catch-all-apply 'vla-put-stylename (list x "Standard")) ) ) ((vl-catch-all-apply 'vla-put-stylename (list b "Standard"))) ) ) ) ) (princ) ) Edited July 13, 2017 by ronjonp Quote
Tharwat Posted July 13, 2017 Posted July 13, 2017 Hi, @ronjonp there is no need to load the library of vla functions every time a user call the command. Quote
ronjonp Posted July 13, 2017 Posted July 13, 2017 Hi,@ronjonp there is no need to load the library of vla functions every time a user call the command. I try to anticipate that the user does not have them loaded already because then the next question is usually: I run your code but get "no function definition: VLAX-GET-ACAD-OBJECT". Quote
Tharwat Posted July 13, 2017 Posted July 13, 2017 I meant to say to load the library once is just enough so you can move it outside the routine. Quote
ronjonp Posted July 13, 2017 Posted July 13, 2017 I meant to say to load the library once is just enough so you can move it outside the routine. I see .. never really thought about it Quote
Grrr Posted July 13, 2017 Posted July 13, 2017 My approach (litterally change the other dimstyles's properties to the "Standard" one) : (defun C:test ( / sdim DimColl e enx ) (cond ( (tblsearch "DIMSTYLE" "Standard") (setq sdim (vla-Item (setq DimColl (vla-get-DimStyles (vla-get-ActiveDocument (vlax-get-acad-object)))) "Standard")) (vlax-for o DimColl (and (not (equal o sdim)) (vla-CopyFrom o sdim)) ) (setq e (entnext)) (while e (and (setq enx (entget e)) (member '(0 . "DIMENSION") enx) (entmod (subst (assoc 3 enx) (assoc 3 enx) enx)) ; <- THIS IS NOT USELESS! It updates the ename - just test the code. ); and (setq e (entnext e)) ); while ); tblsearch ); cond (princ) ); defun C:test Quote
Jamesjh1171 Posted July 13, 2017 Author Posted July 13, 2017 Thanks ronjonp that works beautifully. And thanks other guys for your contributions... Quote
ronjonp Posted July 14, 2017 Posted July 14, 2017 Thanks ronjonp that works beautifully.And thanks other guys for your contributions... Glad to help out Quote
Bluebird1973 Posted July 19, 2021 Posted July 19, 2021 Hi, I tried you code above and on some drawings and it worked very well, but it will not update blocks. I used REGEN and REGENALL, but it doesn't show the DimStyle "Standard". Then I explode the blocks and all DimStyles turned to "Standard". Is there a way to push the REGENALL also to the blocks? Thanks for help! Quote
BIGAL Posted July 20, 2021 Posted July 20, 2021 Maybe attsync a block see if that works, then you would need to go through all your blocks. Not tested. Quote
Bluebird1973 Posted July 20, 2021 Posted July 20, 2021 Hi BIGAL, I tried "attsync" as you recommended me, but don't work. I forgot to mention that I tried both codes above and it looks like that the code from "ronjonp" does the better job..........that's just the opinion of an ignorant user..... sorry.... Please , see attached DWG which I used to try these codes. Perhaps there is something in it, that doesn't allow the blocks to be updated. Test.dwg Quote
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.