Jump to content

Change ALL dimensions to another existing dimension style?


Recommended Posts

Posted (edited)

ronjon did this in vlisp HERE

 

I was wanting to do something similar using regular lisp (to incorporate into a larger existing routine...) - I can maneuver a bit better in regular lisp being a novice too

I was hoping that this would work

 

(defun c:test ()
  (if (setq T3 (ssget "_X" '((0 . "DIMENSION"))))
    (repeat (setq n (sslength T3))
      (setq tdata (entget (ssname T3 (setq n (1- n)))))
      (entmod (subst '(3 . "NewDimStyle") (assoc 7 tdata) tdata)) ;;;NewDimStyle exists
    )
  )
(princ))

 

I changed an existing dimension style using the property manager and the only thing that seemed to change was Assoc 3 - ie: (3 . OldDimStyle) 

 

My code does not work for me...

 

Is this a simple fix?

 

I found this in another post somewhere but did not know if you could mix vlisp/"regular" lisp (and don't know how)

 

(vla-put-Activedimstyle (vla-get-activedocument 
                          (vlax-get-acad-object)) 
                            (vla-item (vla-get-dimstyles 
                              (vla-get-activedocument 
                                 (vlax-get-acad-object))) "Name_dimstyle"))


Because it is going into another routine, I wanted to keep it as compact as possible..
 

 

 

 

Edited by ILoveMadoka
Posted

Should this be a 3 for the assoc and not a 7?

(entmod (subst '(3 . "NewDimStyle") (assoc 7 tdata) tdata))

 

to be

 

(entmod (subst '(3 . "NewDimStyle") (assoc 3 tdata) tdata))

 

Posted

Dang! I was so close!!

 

You are my hero!!

  • Like 1
Posted

..and Thank you!!

Posted

Close - the 2 parts have to match:

 

Posted

I personally hate it when someone has the same issue as me then posts "I fixed it!" and doesn't post their code...

 

Here is the final code:

 

(defun c:test ()
  (if (setq T3 (ssget "_X" '((0 . "DIMENSION")))) ; finds ALL dimensions
    (repeat (setq n (sslength T3))
      (setq tdata (entget (ssname T3 (setq n (1- n)))))
      (entmod (subst '(3 . "NewDimStyle") (assoc 3 tdata) tdata)) ;;;Assumes NewDimStyle exists / replaces the old Dimstyle with the new
    )
  )
(princ))


Thank you again Steven.

  • Like 1
Posted

Thanks ILoveMadoka, hoping in this case that the discussion was clear - but a finished code makes the thread even better!!

 

 

It get's worse of course, people who post and asked a question in a single thread only and then delete their account so you can't ask them for a finished code later,

Posted

I walked away with not only my end goal met but I learned something as well...

 

  • Like 1

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