Jump to content

AutoCAD 2004 Toolbar Button Question...


K2-Kelly

Recommended Posts

Hi All;

 

I'm beginning to learn how to make my own toolbar buttons for ACAD 2004 yet am having trouble figuring out what I would write as the macro command for the operation in the button creation dialog box for a specific operation.

 

There will be 3 buttons. One for .XX, one .XXX, one .XXXX precision edit of an existing dimension. IOW, if I have a 2 place precision dimension and wish it to be 4 place, I'll click the '.XXXX button' then click the dimension and it will change to 4 place. In addition, I'd like for it to update immediately for multiple dimension picks if possible just like 'match properties'.

 

Any ideas?

 

Thanks for your help,

 

K2

Link to comment
Share on other sites

You're looking for a programmatic means to change a given dimension's precision, but you also need to include a check/modify for the dimension's 'supress trailing zeros' property.

 

Consider these LISP examples...

 

Keyboard shortcut:

(defun c:ChgDimPrec (/ ss prec)
 ;; © RenderMan 2011, CADTutor
 (princ "\rCHANGE DIMENSION PRECISION ")
 (vl-load-com)
 (if (and (setq ss (ssget '((0 . "DIMENSION"))))
          (not (initget 7 "1 2 3 4 5 6 7 8"))
          (setq prec (getint "\nEnter DIM precision [1/2/3/4/5/6/7/8]: ")))
   (progn
     (vla-startundomark
       (cond (*activeDoc*)
             ((setq *activeDoc*
                     (vla-get-activedocument
                       (vlax-get-acad-object))))))
     (if (/= prec (getvar 'dimdec))
       (setvar 'dimdec prec))
     (vlax-for oDim (setq ss (vla-get-activeselectionset *activeDoc*))
       (if (= :vlax-true (vla-get-suppresstrailingzeros oDim))
         (vla-put-suppresstrailingzeros oDim :vlax-false))
       (vla-put-primaryunitsprecision oDim prec))
     (vla-endundomark *activeDoc*)
     (vla-delete ss))
   (cond (ss (prompt "\n** Invalid color entered ** "))
         (T (prompt "\n** Nothing selected ** "))))
 (princ))

 

Function which accepts precision argument (for your toolbar macro):

(defun ChgDimPrec (prec / ss color)
 ;; © RenderMan 2011, CADTutor
 ;; Example: (ChgDimPrec 0)
 (princ "\rCHANGE DIMENSION PRECISION ")
 (vl-load-com)
 (if (setq ss (ssget '((0 . "DIMENSION"))))
   (progn
     (vla-startundomark
       (cond (*activeDoc*)
             ((setq *activeDoc*
                     (vla-get-activedocument
                       (vlax-get-acad-object))))))
     (if (/= prec (getvar 'dimdec))
       (setvar 'dimdec prec))
     (vlax-for oDim (setq ss (vla-get-activeselectionset *activeDoc*))
       (if (= :vlax-true (vla-get-suppresstrailingzeros oDim))
         (vla-put-suppresstrailingzeros oDim :vlax-false))
       (vla-put-primaryunitsprecision oDim prec))
     (vla-endundomark *activeDoc*)
     (vla-delete ss))
   (cond (ss (prompt "\n** Invalid color entered ** "))
         (T (prompt "\n** Nothing selected ** "))))
 (princ))

Link to comment
Share on other sites

Thanks for your response RenderMan;

 

Though I understand what you mean about "not" surpressing trailing zeros (as in .25 converted to .2500 would still show as .25), for myself that should not be an issue only ever surpressing leading. However and I'm sure it due to my ignorance, I tried utilizing the script you took time to generate and only received an error message for "too many arguments". Most likely placed in the wrong area as it would not apply to the customize screen, yet only in the current menu area.....In any case in the customize window is where I have made others with some success.

 

cad2.jpg

 

It is within the "Macro associated with this button" pane where I would normally place the text....Is that the correct place for your script above?

 

Thanks for your help,

 

K2

Link to comment
Share on other sites

Hi All;

 

I'm beginning to learn how to make my own toolbar buttons for ACAD 2004 yet am having trouble figuring out what I would write as the macro command for the operation in the button creation dialog box for a specific operation.

 

There will be 3 buttons. One for .XX, one .XXX, one .XXXX precision edit of an existing dimension. IOW, if I have a 2 place precision dimension and wish it to be 4 place, I'll click the '.XXXX button' then click the dimension and it will change to 4 place. In addition, I'd like for it to update immediately for multiple dimension picks if possible just like 'match properties'.

 

Any ideas?

 

Thanks for your help,

 

K2

 

There is a few ways you could do this:

 

1. You could use the following macro on your toolbar button.

 

^C^Cdimdec;4;^C^C-dimstyle;A;\;;

 

You can use this same macro for all the buttons, you will just have to change the value "4" to match the number of places/percision you want the dimensions to be. The problem with this is that you will be creating style overrides for whatever the current dimension style is. To get rid of the style overrides you could add another line to the macro to restore the current dimstyle. But this means that you would have to write in the dimension style name into the macro code. So if you use different dim styles this may not work since the macro will only have the one style name in it that gets restored. Of course if you dont care about the style overrides then it wont matter.

 

2. Speaking of overrides.....you could just select the dims you want to change the percision on and modify them in the propereties screen. This way youre only overriding the dims you select as opposed to the whole dim style.

 

3. You could make different dim style each with the percision level that you want. Then it would just be a matter of doing a properties on the dims you want to change the percision on.

Link to comment
Share on other sites

Thanks for the suggestions CADguy209;

 

I'm not sure it is exactly what I'm looking for yet both your and Renderman's responses are helping me get ideas.

 

Thanks again!

 

K2

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