[Search tip detail and code files using keywords, tip number, author name, etc ]
Dimension in Decimals or Fractions
Tip# 3378 By David White On 22-Mar-2010
Rated By 5 users
Categories : Styles
Software type : AutoCAD 2010
Rename File To : No Files to download.
This routine asks you if you want to dimension in fractions or in decimals.

Manufacturing Engineer David White sends us a routine he wrote to help himself dimension properly, and to fit his design needs.

"I've been designing with AutoCAD for more than 25 years. I was taught years ago that one should design with care, and that unnecessarily close tolerances should be avoided to keep manufacturing costs down. I've always had a tolerance block in my title block that states the number of decimal places a dimension is given so that it infers a particular tolerance, as well as a standard tolerance for fractions.
"I never really thought about writing a routine to assist me in dimensioning until I got AutoCAD 2010. I design things that have a need for three decimal places on a part, and fractional dimensions on the same part when that dimension is not to be held that closely. I mean, if it's just hanging out there in the air, why should it be +/-.0005?
"So I wrote the following routine, and made up the name 'spdim' for no particular reason.
(defun c:spdim()
 (initget "F D")
 (setq dse(getkword "Type: Dec/Frac<current>")) ; first I inquire if the dimension is to be a fraction or a decimal, it won't change from the previous type if I just press Enter
 (if(= "F" dse)(setq ds 5)); then I evaluate what the response was, and set another variable to be used
 (if(= "D" dse)(setq ds 2)); to set the variable DIMLUNIT
 (setvar "dimlunit" ds)
 (if(= 2 ds)(setvar "dimdec" 3)); then I check if the DIMLUNIT is a decimal, set the precision to three places
 (if(= 5 ds)(setvar "dimdec" 5)); if the DIMLUNIT is a fraction, set the precision to five places (close enough for me)
Now the CUI (customize user interface) macro for the horizontal, vertical, and diameter dimension command looks like the following. (Please note that GL, SD, and SPV are other routines that retrieve the current layer variable, set the layer to DIM, and set the layer back to the previous layer respectively. These routines are in my ACAD.MNL file).
^C^Cgl;sd;spdim;; dim;hor;\spv;
Substitute hor with vert and dia for the other type dimensions.
Some may not like dimensioning decimal or fractions on the fly, but I prefer not having to reset the dimstyle in the middle of dimensioning a component.

Notes from Cadalyst Tip Patrol: There are so many ways to customize what we do in AutoCAD that it can become cumbersome to switch between styles. This routine asks you if you want to dimension in fractions or in decimals. The second set of code goes into a button. That button could be in the ribbon, pulldown menu, toolbar, or tool palette. If you don't have the tipster's extra routines to add in, then the CUI (custom user interface) code should look like this:


As stated, the hor is for horizontal dimensions. Substitute that in another button with vert for vertical dimensions, and so on.


Average Rating:

User comments
Comment by nemirovsky,len
Posted on 2010-03-24 17:45:28
It does work very good