Hot Tip Harry: Tips from our Readers -- August 2005

14 Aug, 2005 By: Bill Kramer Cadalyst

Great Visual LISP utilities for creating 3D points, enhancing AutoCAD commands, scaling and rotating multiple objects, and much more.

Download code for this and all articles. Look for AUG05.exe in Get the Code. Downloads are free and are provided "as is" without warranty or support.

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. From a pool of reader-selected monthly winners, our judges will pick the Top Tip for 2005. The first prize is $1,000. Second place wins $500 and third place, $250. E-mail those tips and tricks to

The hot summer months mean nothing to Hot Tip Harry and his fans. Instead of lying around doing nothing, the tipsters are busy in their air-conditioned lairs. The temperature is always perfect here in cyberspace. Harry is still on the prowl though. He heard some rumbles in the street about the new menu system in AutoCAD 2006. Harry was a tad confused by it at first as well, and he is seeking tips that demonstrate how to take advantage of the improved system and get the results we used to get from the old way of doing things. For this month he is passing along a variety of utilities, some simple, some rather complex. He has things sure to delight all levels of Visual LISP students and masters.

Creating 3D Points
Pedro Ferreira sent a tip for Creating 3D Points at the Location of Selected Text Objects (Tip #2047). This utility is a simple LISP module containing the function PMSFPTWTXT. The function will ask you to select text objects containing the elevation value. That is, you create text objects where the value of the text is the elevation (z value) you want to use. The text may be the result of another custom application that reads data. The text is extracted from each text object in the selection set and used to formulate the z value of a point. The x and y values are obtained from the text object itself. The resulting point is placed in 3D on a layer with the same name as the command PMSFPTWTXT. This tip is a great seed module that you can modify to make use of z values in text that need some conversion before use. Thanks, Pedro!

Queuing Up Objects
Queue Up Text and MTEXT Objects for Edit Operations (Tip #2048) from Syd Derbyshire demonstrates how to enhance the basic operations of standard AutoCAD commands to match your style. In Syd's case he wanted to select a bunch of text and mtext objects first and then have the program loop through the selection list presenting the dialog boxes to edit each of the objects selected. Load the LISP code and then type MME to use Syd's approach. Short and sweet macros make the day brighter!

Scaling and Rotating Multiple Objects
Jamie Spartz sent Harry two tips based on the same premise. Scale Multiple Objects (Tip #2049) and Rotate Multiple Objects (Tip #2050) both let you select a set of block insert objects and then the same edit operation is performed on all of them. These utility routines are another example of simple LISP modules that you can clone into other useful edit functions of your own design. To use, load the LSP file and type MSCALE for the multiple object scaling or MROTATE for multiple object rotation. The scale and rotation are applied at the insert point of the blocks selected. A very handy set of base routines when working with drawings containing blocks that you need to adjust. Programmers can modify Jamie's simple approach for a variety of commands and object types such as rotating text from one orientation to another.

Converting to Millimeters
Modified Offset Command (Tip #2051) from Jason Longmire is a simple function that accepts input in feet and inches, and then converts to millimeters for use in the Offset command. This is a classic example of a function that was coded to quickly solve a problem at hand. Just load the LSP file and type OI to get it started. The conversion of inches to millimeters is performed with a simple multiplier to the distance value input. Harry thanks Jason for sharing his tip and beckons readers to take a look at the Visual LISP (CVUNIT) function for similar conversion requirements.

Isometric View Planes
ISO View Drafting Tool (Tip #2052) from Lloyd Beachy is a really nice function. Not only is it well written, but it contains several

Figure 1. An ISO dialog box allows you to select one of the views, courtesy of Tip #2052.
well-executed programmer tricks. Harry's favorite is the built-in DCL file generator -- very nice. Draw the basic object in 2D to get started. Load the LSP file to enable the ISO command. When you type ISO at the command line, a dialog box (figure 1) showing different isometric view planes will appear along with a series of toggles for the type of objects you want to select. Pick one of the views. The program then asks you to select objects for conversion to the new view orientation. Select the objects, and then provide a base point and relative displacement for the placement of the isometric view. The objects you selected are redrawn (leaving the originals intact) using the isometric view. Great tip, Lloyd, and nice coding too.

Save Text to MS Word
Andrzej Gumula sends another clever example of object manipulation in Visual LISP with Save Text into a MS Word File (Tip #2053). Load the LISP code, and type SAVE2DOC (or SD for short) at the command line. You must have Microsoft Word installed on your computer for this utility to operate correctly. For anyone wanting this type of functionality in AutoCAD and Word, the utility is very useful. However, I strongly recommend it for students of advanced Visual LISP applications, as this is a very clear example of writing documents in Word using LISP. Thanks for another great tip for all of us, Andrzej!

Harry wanted to pass along a nice tip for those readers who do programming in older versions of AutoCAD and suffer from the "someone reset Pi" problem. In Visual LISP you can sometimes encounter a situation where someone else left the value in the symbol Pi set to an incorrect value. To remember, use the following expression, but only if you really need it!

(if (not (equal PI (* 4 (atan 1))))(setq PI (* 4 (atan 1))))

Visual LISP helps to keep those kinds of situations from coming up by alerting the programmer to the blunder of setting a symbol like Pi, but after seeing a couple street routines containing Pi resets, Harry was concerned. Keep on programming, and don't stop sending those tips!

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!