Hot Tip Harry15 Dec, 2004 By: Bill Kramer Cadalyst
Layer controls and tricks with text.
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.
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.
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>.
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.
In her easy-to-follow, friendly style, long-time Cadalyst contributing editor and Autodesk Technical Evangelist Lynn Allen guides you through a new feature or time-saving trick in every episode of her popular AutoCAD video tips. Subscribe to the free Cadalyst Video Picks newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!