Hot Tip Harry: Tips from our Readers -- April 200515 Apr, 2005 By: Bill Kramer Cadalyst
A sprocket drafting utility, a Quick Snap angle setting interface and routines to mirror in four quadrants, add architectural units and adjust text for all drawings in a directory.
Expert system tips and tricks are small routines that solve the specific drafting needs of an expert in a particular discipline. An expert drafting utility program generally accepts input from the operator and automatically draws a set of objects based on the input parameters and a set of programmed rules. Harry thinks there are lots of such useful utility tips and tricks out there and is looking for them to include in our library.
As an example of an expert system tip, the first tip of the month comes from Don Grauel. Sprocket Drafting Utility (Tip #2024) creates a view of a sprocket given just the basic input of the chain size (number), tooth count, center point and tooth type. If you draw lots of sprockets in your designs, you are going to love this very effective drafting tool. After downloading the tip, load it using Visual LISP and type in DJG_RCS at the AutoCAD Command line. You will be prompted at the Command line for chain type (designated by industry standard numbers), number of teeth in the sprocket, whether or not to use the sharp tooth type and the center point. The rest is automatic and a real time saver. The answers to the previous run of the utility are remembered as the defaults for the next time around. This is a well-constructed program that can match your own shop's drawing standards with just a little tweaking of the LISP code.
Quick Snap Angle Setting
Figure 1. Slopes are represented as ratios in the dialog box.
Alternate Approach to Architectural Units
Jim Himes supplies the next example in Adding of Architectural Units (Tip #2026). Visual LISP programmers know that the architectural units style in AutoCAD can sometimes be difficult to work with consistently. Even though the AutoCAD subroutine DISTOF provides a way to interpret those dimensional values created using the same rules as AutoCAD, it is helpful to have alternatives at the ready. Jim supplies that alternative in his utility ADD-TEXT. Load the LSP code supplied and type Add-text at the Command prompt. You will then be asked to select an architectural text value (text or dimension) to serve as the first number. Subsequent selections are added to build a cumulative result. Not selecting an object to addition causes the program to ask for your selection of a text object for placement of the total text. Not only do you get another way to convert architectural units into something you can manipulate, but this utility comes in really handy when creating bill of materials lists.
Mirroring in Four Quadrants
Quad Mirror Text (Tip #2027) comes from Aaron Johannsen. Aaron's Visual LISP lets you define a center point and selection box from that point for text and Mtext objects to be mirrored in all four quadrants. The need for this tool grew out of the problems one can encounter when designing apartment units that are mirrored about each other. Load the LSP file and type Qmir to activate the routine. First select the center point about which the text will be mirrored. Then select the opposite corner of the existing text in the drawing. You'll see the text and Mtext objects magically mirrored about both the x- and y-axes, creating four copies of the same thing. This utility makes mirroring text easy!
Adjust Text for All Drawings in a Directory
Our last tip of the month is another monster cool routine from Andrzej Gumula in Poland. Adjust Text for All Drawings in a Directory (Tip #2028) demonstrates how the AutoCAD object system as exposed in Active X can be exploited by Visual LISP. One problem that has always plagued LISP programmers in AutoCAD is how to exploit the system's tools in Windows, and Andrzej demonstrates how easy it is using objects in AutoCAD. Plus, this handy utility can be used for title blocks, drawing notes and so forth to update complete projects with a single command. This utility consists of a LISP source file and a dialog box DCL file. Place the dialog box file in a directory where AutoCAD can find it. Then load the LISP file and type Reid at the AutoCAD Command line. A dialog box will appear with the options available as shown (figure 2).
Figure 2. In Adjust Text for All Drawings in a Directory, this dialog box prompts you for the text you wish to change.
Enter the text to be changed, select the directory to search and select the various search-and-replace parameters you want, then press OK to let it fly. This utility goes through the folder selected and replaces any text found, all the while reporting the progress at the Command line in AutoCAD. This routine is brilliant, and Harry tips his hat to the programming genius Andrzej!
Keep those tips flowing in!
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!