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

15 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.

Download code for this and all articles. Look for APR05.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 following tips are not April Fools, they are the real thing." The message repeated over and over until I entered the secret password Harry had given me. The CD must have been left at the drop spot the night before. Wrapped in brown paper, it was soaked from the April showers that turned the air into a dank, humid stink and the ground into a muddy mess. Harry's message continued: "These tips are from trusted sources. Please share them with your readers and let them know we are looking for more expert system tips and tricks."

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.

Sprocket Drafting
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.
Another example of an expert interface is Quick Snap Angle Setting (Tip #2025) by Bill Barlow. This utility involves a dialog box along with a Visual LISP program module, named QS.DCL and QS.LSP, respectively. Place the DCL file in a directory where AutoCAD can find it and load the LSP file. Then type QS at the Command prompt. A dialog box full of radio buttons will appear that will allow you to select the desired slope up or down. Specify one of the slopes and click OK to have the snap angle reset to the selected slope. Slopes are represented as ratios in the dialog box (figure 1). A slope of 4/12 means that the y-axis value changes 4 units for every 12 changed along the x-axis.

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!

About the Author: Bill Kramer

AutoCAD Tips!

Lynn Allen

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!

Follow Lynn on TwitterFollow Lynn on Twitter

Which device do you typically use to read content?
A desktop computer / tower workstation
A tablet
A smartphone
A laptop or mobile workstation
I regularly use both a desktop computer and a smartphone for this purpose
I regularly use another combination of devices for this purpose
I prefer to print out articles from the website and read them on paper
Submit Vote

Download Cadalyst, Fall 2015

Download Cadalyst Magazine Special Edition