Jump to content

Change all existing dimstyles to standard with a LISP


Jamesjh1171

Recommended Posts

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.

Link to comment
Share on other sites

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 by ronjonp
Link to comment
Share on other sites

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". 8)

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 years later...

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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