Hot Tip Harry

Tips to measure lengths, make patterns, tidy your text, and more.

GET THE CODEDownload the code for this and all Cadalyst articles. Look for file APR04.exe in Get the Code.

Tips included in Hot Tip Harry are tested with AutoCAD 2002 and 2004, 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 downloaded or copied for commercial purposes. Tips are uploaded to the Get the Code area. Look for a file named APR04.exe. Downloads are free, but you need to register. Downloads are provided as is without warranty or support. All published tips are entered into the annual Hot Tip Harry Contest. From a pool of reader-selected monthly winners, our judges will pick the Top Tip for 2004. The first prize is $1,000. Second place wins $500, and third place, $250. E-mail those tips and tricks to harry@cadalyst.com.

A SHIP FULL OF CAD CRUISERS slipped comfortably into the pier as the sun rose above the hills to the east. Exotic smells and sights filled my senses as I ventured on deck to take it all in before the rest of the ship awoke. I felt a presence next to me and turned to find Harry enjoying the view, too. He handed me a tattered envelope. "Check these out," he said. "Here's some cool stuff for your CAD Cruise classes to ponder. Oh, and remind your readers to vote at www.cadalyst.com on which tip they like best."

Harry really liked the two functions supplied by Will DeLoach because they show the true power of Visual LISP to create utilities. Tips #1939 (C:LL) and #1940 (C:OL) are two great examples of how Visual LISP works well with AutoCAD objects. The first is a command function named (C:LL) that you use to measure the length of linear objects. Load the file HTH1939.LSP and type LL. Select linear objects such as lines, arcs, polylines, and so forth. By using the Length property of AutoCAD objects, this function quickly computes the sum of lengths. Will's second tip is found in file HTH1940.LSP and named OL, for offset line. This function creates a pair of offsets on either side of a linear object with the option to remove the original center object when finished. It's useful for drawing walls, highways, and other offset groups.

Tip #1943 from Theodorus Winata, found in file HTH1943.LSP, contains a Visual LISP command function that merges text objects. This function is quite helpful when you want to line up a series of notes. Place text notes as you work in the drawing off to the side. Then, to run the program, load HTH1943.LSP and type JMT. The routine asks you to select two text objects. The result appends where the first text object is. The second text object selected is added to the end of the first as a new line. When you select an mtext object with multiple text lines first, the program adds the merge text at the bottom after it adds a new line. When you select a regular text object first, the merge text appears with the expanded characters for mtext appended to the end of the original string.

Theodorus also provides us with another great function that uses dialog boxes and integrated slides for helpful graphics to guide you through creating a breakline. Tip #1944 is supplied in a compressed file named HTH1944.ZIP that contains three files, all named LSB. Place these files in your AutoCAD search path. To use the custom breakline drawing utility, load the Visual LISP code stored in LSB.LSP, then type LSB at the Command line. A dialog box appears to help you draw breaklines and tubes quickly. This is a nice example of a parameter-driven function that uses a graphic dialog box. Thanks for the tips!

Another example of meaty AutoLISP code is a useful application for inserting weld symbols, Tip #1945 from Jerel Walker. It comes compressed in HTH1945.ZIP. This tip was written in Visual LISP and includes a dialog box to select the symbols you want to use. Save the LSP and DCL files in your AutoCAD search path and load WELD.LSP before typing Weld at the AutoCAD Command line. Weld has a series of fields in the dialog box that you select to build the type of welding symbol you want to draw. This is a great example of parametric programming.

When you load Tip #1946 from Mike Hauptman, the (math) function is available from the Command line to perform simple arithmetic functions in a dialog box. Run Math, then type 1+3 and press to see the result of 4. For those programmers looking for an interesting way to supply a dialog box in a program, check this one out. Study the natural language parser, because it's structured in an interesting manner as well.

KEEP 'EM COMING
Harry and all involved thank everyone who submits tips for consideration. See the box below on how to submit a tip. All types of tips are welcome, including menus, patterns, symbols, Visual LISP, VBA, and ARX.

About the Author: Bill Kramer

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!