Hot Tip Harry: Tips from our Readers -- August 200515 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.
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.
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!
Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's free Tips & Tools Weekly e-newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!