Jump to content

Modifying Dimension Style using lisp


briankstan

Recommended Posts

I searched but didn't find anything.

 

I have a drawing with several different dimension styles that have the alternate units turned on and the are displayed in Millimeters, now the Architect would like them Displayed in Meters.

 

I can't figure out how to change the dimension style with the corrected info. I have to update about 100 drawings with at least 3 dim styles in each drawing. I know I can change it using Dimstyle, but I'd rather automate the process if I can.

 

I need to modify the existing dimstyle without using dim overrides.

 

thanks for your help.

Link to comment
Share on other sites

Try this mate:

 

(defun c:alt (/ doc)
 (vl-load-com)
 (vlax-for dim (vla-get-Dimstyles
                 (setq doc
                   (vla-get-ActiveDocument
                     (vlax-get-acad-object))))
   (vla-put-activeDimstyle doc dim)
   (setvar "DIMALTF" 0.001)
   (vla-copyfrom dim doc))
 (princ))

Link to comment
Share on other sites

I see it created a few new ones,

 

What I'm looking to do is modify the existing ones to new settings, without having to do each one individually.

Link to comment
Share on other sites

I see it created a few new ones,

 

What I'm looking to do is modify the existing ones to new settings, without having to do each one individually.

 

It shouldn't have created anything :huh:

Link to comment
Share on other sites

Its supposed to do what you requested it to do... :wink:

 

Changes the Alternative Units Multiplier to 0.001 to convert mm to m.

Lee,

 

I would assume that only will apply to the current dimstyle?

Link to comment
Share on other sites

Well, that is what was requested. :wink:

 

Ok, But if you were using a drawing with multiple viewports with different scales, You might not want to change all of them.

 

Just a thought.

Link to comment
Share on other sites

what I have to change in the dimstyle is the following

 

Multiplier for alt untis: 25.4 to .02540

Suffix: from MM to M

 

this sets the dimstyle to display correctly once I save it.

 

is there a way to just change those on specific dim styles?

Link to comment
Share on other sites

what I have to change in the dimstyle is the following

 

Multiplier for alt untis: 25.4 to .02540

Suffix: from MM to M

 

this sets the dimstyle to display correctly once I save it.

 

is there a way to just change those on specific dim styles?

 

yes, but none of this was specified in the OP... :unsure:

Link to comment
Share on other sites

yes, but none of this was specified in the OP... :unsure:

 

 

sorry I wasn't very clear in my OP, I can see that it would work, but it seems I would have to manually update the dims, as they don't automatically update when the change is made.

Link to comment
Share on other sites

Try to explain the whole problem next time, but this should sort you:

 

(defun c:alt (/ dimlst doc ss)
 (vl-load-com)

 (setq dimlst '("DIM_STYL1" "DIM_STYL2")) ;; Change as necessary
 
 (vlax-for dim (vla-get-Dimstyles
                 (setq doc
                   (vla-get-ActiveDocument
                     (vlax-get-acad-object))))
   (if (vl-position (vla-get-Name dim) dimlst)
     (progn
       (vla-put-activeDimstyle doc dim)
       (setvar "DIMALTF" 0.02540)
       (setvar "DIMAPOST" "M")
       (vla-copyfrom dim doc))))

 (if (setq ss (ssget "_X" '((0 . "DIMENSION"))))
   (mapcar 'vla-update
     (mapcar 'vlax-ename->vla-object
       (mapcar 'cadr (ssnamex ss)))))
 
 (princ))

 

Update list as necessary.

  • Like 1
Link to comment
Share on other sites

sometimes trying to figure out these lisp things I really feel like the computer it really taking to me. lamo.gif

 

but once I get them working, usually with others help it sure is nice. biggrin.gif

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