cadalyst
AutoCAD

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

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


GET THE CODE
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 harry@cadalyst.com.

"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
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
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


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!