Hot Tip Harry

14 Dec, 2004 By: Bill Kramer Cadalyst

Layer controls and tricks with text.

Download free code for this and all articles. Look for DEC04.exe in Get the Code.

Tips are tested with AutoCAD 2005, unless otherwise noted. By submitting code to Cadalyst, you grant Cadalyst the right to print and distribute your code in print, digitally, and by other means. Cadalyst and individual authors retain all rights to the code, and it is not to be used for commercial purposes. All published tips are entered into the annual Hot Tip Harry Contest. Find out more online, and e-mail your tips and tricks to

"HAPPY HOLIDAYS FROM HOT TIP HARRY," read the cover of the CD that arrived in a plain brown wrapper. I checked for a return address, but as usual there wasn't one. I dropped the CD into my workstation, and the automatic run started a video of Harry sitting in a run-down diner talking into the computer microphone.

He spoke quickly, "I've been laying low since that incident at the casino. . . but you don't want to know about that. Instead, let me lay some more hot tips from the field on you. Two cases are still open: layer controls and text manipulations. Hope these make those jobs easier. Harry out."

Actually, I'm more curious about the casino incident than the tips, but that'll have to wait.

Layer Mania
Inspired by a recent thread in the Cadalyst Newsline e-mail newsletter on making sure dimensions end up on the right layer, Jack Foster submitted a series of AutoLISP routines, Dimension Layer Macros (Tip #1997). These simple routines combine AutoCAD commands into a single stream to control layering. All the functions are contained in dimautolayer.lsp. Once you load this file, you have new commands available to switch the active layer to DIMS and then perform your dimensioning command of choice?DL for Dim Linear, DR for Dim Radius, DA for Dim Aligned, and DD for Dim Diameter. After the dimension command is complete, the active layer returns to the previous setting. One thing I liked about this set is that it's a simple example of how to use the CMDACTIVE system variable.

For those looking to expand on Jack's idea, check out Layer and Command, Menu Combination Tool (Tip #1998) by Steve Johnson. This is a cool menu programming tool. Instead of swapping layers around in the menu, Steve combined the Layer command with your choice of standard AutoCAD commands. He supplies two command functions in the laycmd.lsp file. LAYCMD and the expanded LAYCMDS request a layer name and then a command. The command starts, and once again the CMDACTIVE system variable is demonstrated as the LISP function waits for the command to complete before restoring the active layer.

Glenn Swaney raises the bar a bit further with Viewport Dimension Tool with Menu (Tip #1999). This set of files includes some LISP code, a menu, and the icons for the menu as BMP files. Place the complete file set into one of the AutoCAD support paths that are searched regularly. Then load the LISP code Vpdim. This code automatically loads the menu and a set of new dimensioning tools that works in scaled and locked viewport displays.

Text Routines
Jeffery Sanders gives us Get and Display Area (Tip #2000), an elegant and simple function. Load the ga.lsp AutoLISP file and then type GA at the AutoCAD command line. Select a point inside an area, and it's labeled with a number, the area in current drawing units, and the perimeter of the area. The current text style is used for the label centered on your pick point. The setting in the AutoCAD system variable USERI1 controls the value of the number displayed. It starts with a value of 1 and increments by 1 each time you use the GA command.

Tom Beauford's Draw Box Around Text (Tip #2001) supports regular text, multiline text, attributes, and rotated text. Load the tbox.lsp routine and type Tbox at the command line to activate this handy utility.

From Poland comes Text Along Arc or Polyline (Tip #2002) by Andrzej Gumula. This well-constructed AutoLISP function draws text along an arc or a polyline object. Draw a polyline and include some arcs. Load the curve text.lsp file and type Curvetext. It asks you to select the geometry and supply offset information to align the text along the object selected. The last input request is for the text. It appears in the drawing after you press <Enter>.

Bonus Tip
Parse INI File Utility (Tip #2003) is the last tip of the year. It's not really a command tip, nor was it submitted as a tip. It's a special present for Harry's loyal readers. This function reads text files that are formatted as Windows INI files and returns a data list. An INI file contains a series of sections denoted with square brackets. Each section contains property information defined with a name and value separated by an equal sign. This standard data file format works well as a nested list when read using the PARSE_INI routine. Thanks and a tip of the hat from Harry! Keep those tips coming in.

About the Author: Bill Kramer

More News and Resources from Cadalyst Partners

For Mold Designers! Cadalyst has an area of our site focused on technologies and resources specific to the mold design professional. Sponsored by Siemens NX.  Visit the Equipped Mold Designer here!

For Architects! Cadalyst has an area of our site focused on technologies and resources specific to the building design professional. Sponsored by HP.  Visit the Equipped Architect here!