[Search tip detail and code files using keywords, tip number, author name, etc ]
 
Units, Areas, and Acaddoc.LSP
Tip# 3884 By Frank Kellogg On 07-May-2012
0
Rated By 0 users
Categories : Units
Software type : AutoCAD 2013
Rename File To : No Files to download.
Use these two macros to quickly set your units to the settings you want to use.

Tipster C. Frank Kellogg shares two small bits of code that he uses to quickly switch the "read-out" units for text in AutoCAD.

"I work in decimal inch units (and dimension in fractional inches to 1/16" or 1/32"). Frequently, I need to know something like square feet instead of square inches, for instance. I have the following bit of code included in my acaddoc file, along with more than 200 other defun keyboard shortcuts that are not possible via the acad.pgp file.

    (defun C:du ( ) (setvar "cmdecho" 0) (command "units" "2" "6" "1" "5" "0" "n") (setvar "cmdecho" 1)
       (princ "Measurement Units Set To My Decimal Preferences" )(princ) )

    (defun C:au ( ) (setvar "cmdecho" 0) (command "units" "4" "16" "1" "1" "0" "n") (setvar "cmdecho" 1)
       (princ "Measurement Units Set To Architectural Preferences" )(princ) )

"To set the six values after the 'units' command, go to AutoCAD and enter -units at the Command line (note the hyphen). AutoCAD very helpfully opens up the text window, so you can see what your numerical choices are; I normally use 2 for decimal, and use the code to switch to 4, architectural. Follow the Command line prompts to note which values you want to set with the code, and write them down.

"I really only know the defun function in AutoLISP, so I must have copied this bit of code from something else I found on the Cadalyst CAD Tips site. I don't know why the setvar cmdecho is in there; none of my other defun keyboard shortcuts have it. (However, in testing some of those that don't have it, I see where it could clean up the output to the text window.) I have the bit of text appear after all of my defun commands, mostly for fun, to remind myself it's one of mine. Also, because I have limited LISP programming knowledge (working strictly in Notepad text files), some may notice that I use parentheses in more of a spreadsheet manner, instead of placing them on different lines, like I see in other Tips (that method confuses me). I just make sure I count equal numbers of open and close parentheses, just as I must do in my estimating spreadsheets.

"With this bit of code, I can switch units instantly, rather than the laborious menu bar method, with pull-down, slide over, multiple check boxes, etc. AU, Enter. DU, Enter. It's so simple. Of course, this will not affect your dimension units at all. I change the alternate units to 1 and the units there to architectural, but that's another tip."

Notes from Cadalyst Tip Reviewer Brian Benton:
This is a nice bit of simple code. They are just macros, but they quickly set your units to the settings you want to use. You could edit these to fit any of your unit needs. Follow the tipster’s advice and type -units on the Command line, making sure to include the hyphen (-). This will run the command on the Command line, showing you each possible value for each setting. Write down which options you want and edit the code accordingly.

 

Average Rating:
0


User comments


Log In