Tips from Our Readers -- June 2007 (Hot Tip Harry AutoCAD Tutorial)1 Jun, 2007 By: Bill Kramer
Power tools for AutoCAD programmers.
Join the Hot Tip Harry Challenge
Calling all tip writers! The Hot Tip Harry Challenge is under way for 2007 and is sponsored by Autodesk. Share your hot tips and tricks for a
Harry's tips for this month are a selection of power tools submitted by your fellow AutoCAD users. Automation starts with simple steps and the tips that follow are just a few examples that you might find useful. They're also examples in which you can study the source code, learn a few tricks and make your own versions to improve your productivity. When your coworkers start to use your home-grown macros, you will gain a level of job satisfaction that can't be measured.
Slope Annotation Tool (Tip #2211) from Andrew Siddeley kicks off the tips for this month. Consisting of three files, one LISP module and two drawing blocks, this routine calculates the percentage slope from one point to another given the elevation spot data. To use this routine, place the drawing blocks somewhere on your hard drive that AutoCAD searches. Insert the block SPOT at least twice in the drawing. When you insert the SPOT block, it prompts for the spot elevation attribute value. After inserting at least two spots, load the LISP code and type SLO at AutoCAD's Command prompt. It requests that you pick the two spot blocks (highest first) and asks you to select an existing slope data block or just press Enter to have one inserted for you. The slope is shown as a percentage inside the slope data block. You can adjust the blocks to fit your drawing style, and this well-written LISP module shows how easy it is to adjust attribute values inside AutoCAD. Great tool, Andrew! A tip of the hat from Harry!
DIMASSOC Counter (Tip #2212) by W. Kirk Crawford looks at all the dimension objects in a drawing and counts up how many have the DIMASSOC variable set to 1 or 2. When DIMASSOC is set to 1, the dimension is considered nonassociative, which means that it doesn't change when you change the geometry. A setting of 2 indicates a properly associative dimension that changes value when you change the geometry. To check the dimensions in a drawing, load the drawing and then the LISP code for this tip. Type DIMCK at the Command prompt after loading and the totals appear in the AutoCAD text window. The source code for this routine contains lots of deeply nested parentheses pairs and is a brilliant example of how to navigate into the block details of an AutoCAD drawing.
Dynamic Fillet (Tip #2213) by Lloyd Beachy is an innovative approach to creating a fillet between lines and arcs. Load the LISP code and type DFILLET at the Command line to activate the function. Just like the regular Fillet command in AutoCAD, this function starts by asking you to select two objects. The objects selected must be lines or arcs. You also are given the opportunity to change the radius that will be applied to the initial fillet. After the fillet is created, a loop is started where you can press the plus or minus keys to increase or decrease the size of the fillet dynamically. Each time you press the plus or minus, the fillet value is changed by a factor of two raised to the one-tenth power (2^0.1) or approximately 1.07. For example, pressing plus results in a fillet that is 1.07 times larger. This utility is fun to run, and it is this month's top tip, congratulations Lloyd!
Add Tolerance Factor (Tip #2214) by S. Ramakrishna automatically appends tolerances based on your input to dimension objects you select. This utility is a fast and easy way to add tolerance factors and clearly shows how to use the fancy codes in text objects for your own needs. Run this utility after you create the initial dimensions in your drawing. Load the LISP code and type TL at the Command prompt. First, enter the upper tolerance factor, including the decimal. Next, enter the lower tolerance factor (don't add the minus sign, it's implied). Lastly, select the dimension objects you want to change. After you select the last dimension object, the tolerance factors are added automatically to the selection set. Nicely done! You'll find this tip very useful if you use tolerance dimensions.
Match Elevations (Tip #2216) from Pedro Ferreira is another tool for correcting drawings. The purpose of this utility is to change elevation properties in AutoCAD objects such as hatches, polylines and sections. In other words, you can change those objects with an elevation property embedded inside them with this function. Objects that have 3D points don't have a single elevation property and can't be changed. This function illustrates how programmers can use the Get and Put methods to manipulate properties after a function has an entity object ready to process. Very powerful edit tools can be created from these functions, and Ferreira has provided a very clear example of how to do it.
Quick Snap Sets (Tip #2217) by Mitchel E. Thaxter is a quick and simple set of functions for establishing object snaps. The code includes four command functions based on the plus and minus keys. You can quickly adjust these commands to match your preferences for object snaps just by changing the constant values used (see source code for values). After loading the LISP code, four new commands are available. To change the object snap mode to everything, type the plus key twice and press Enter. To change the object snap mode to nothing, type the minus key twice and press Enter. Quick mode adjustments like this are easy to code in LISP, and they provide a nice power tool for regular AutoCAD users.
Curve Details (Tip #2218) by Alireza Edalatipour generates all the details you need to know about an arc in AutoCAD as text. Load the LISP code and type CUB to activate the command. It asks you to select an arc object (curve) and a point where you want the details displayed. The function then annotates the end points of the curve, the throw point (intersection of tangents from end points) and presents the curve details at the location you select. Curve details shown are the included angle, radius, tangent distance, arc length and external distance. These values often are used in route location and design for highways. This very useful power tool shows how easy it is to extract information from entity objects and create annotations using regular AutoCAD commands.
Keep 'em Coming!
These contributions are a great set of tips from all over the world. Harry really appreciates being part of this international community of AutoCAD power tool users and hopes you can help by sending in your own tips and tricks. Be sure to include all the source code needed to operate the tip -- and don't forget to include your contact information. Who knows, you may be sporting a "Hot Tip Harry" Cadalyst T-shirt in the near future and even jetting off on a trip to AutoCAD University. Until next time, keep on programmin'.
In her easy-to-follow, friendly style, long-time Cadalyst contributing editor 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!