Search This Blog

Friday, February 18, 2005

Dimension and Accuracy Checking via AutoLisp

Toggle between Architectural Units and Decimal Units

Ever get a drawing from someone else and you can't quite figure out why certain elements don't quite fit with some of your existing drawings? Chances are someone took a shortcut and didn't draw the objects or entities entirely accurately. If you suspect this is the case with the file you are working with you might switch your units and update the dimensions. I wrote the following toggle to assist in this check.


(defun c:ut (/)
(prompt "\nMacro: Unit Style Mode Toggle by RLB!")
(if (/= (getvar "lunits") 2)
(progn
(setvar "lunits" 2)
(setvar "dimunit" 2)
(prompt " Decimal Units ")
)
(progn
(setvar "lunits" 4)
(setvar "dimunit" 4)
(prompt " Architectural Units ")
)
)
(princ)
)



You can call this at the command line once it is loaded into your AutoCAD session by typing "UT" without the quotes and using the "rule of thumb" or "Enter" key. This macro will toggle from Architectural units to Decimal and vice a versa reporting the current setting at the command line.