Hot Tip Harry: Tips from our Readers -- February 200514 Feb, 2005 By: Bill Kramer Cadalyst
Shortcuts to annotating MCAD drawings, scaling donuts, hiding toolbars and more
"You know what I like most about being on the Web?" he said. "You get stuff from all over the world. I have some really hot stuff for you to share with everyone. These should warm things up for your readers during the cold months up north."
Flipping his laptop onto the table, Harry started into them right away.
Rick Schwier provides the first tip, with a tool for annotating drawings in the manufacturing world. Surface Quality Annotation (Tip #2011) places a surface finish mark at a point specified by the operator using the current dimension system variables to control the size. Load the LSP code and type the command Surf. Enter the surface quality value, select a point and the rest is automatic. Simple combinations of AutoCAD commands with Visual LISP continue to provide some of the most practical tips in Harry's bag of tricks. Thanks Rick!
Donut Scale (Tip #2012) from Richard Paquette is another example of a simple but time-saving macro that makes use of the existing commands and LISP to get the job done. The utility scales donut objects while retaining their original position. Born from having to adjust patterns of rebar cross sections represented as donuts in AutoCAD (closed polylines with thickness), this utility shows that necessity is indeed the mother of invention.
For something different, take a look at Disappearing Toolbars (Tip #2013) from Leo Nemirovsky. The download contains two files, a menu source (MNU) and an associated LISP set (MNL). Use Menuload to load the MNU source. While still in the menu customization dialog box, switch to the Menu Bar tab and add the DTB menu group to the Menu Bar. DTB should appear in the pull-down menu and, when selected, found to contain four entries. Each entry will bring up a toolbar menu that goes away once anything is selected from it. AutoCAD users who like toolbar menus but don't like having them all over the screen all the time should download this tip and adapt the methods used. Great job, Leo -- this is cool.
Our next tipster, Alexander Smirnov, supplied three wonderful functions that demonstrate the power of Visual LISP object handling. The first, Text Alignment (Tip #2014), is for aligning text in a drawing. Load the LSP file and then type in the command Dali. Supply answers to prompts about the spacing factor to use, then select text objects. The text objects will be lined up under the top-most (greatest y-value). This utility uses object references for all the text manipulations and is an excellent example of advanced Visual LISP programming.
Alexander's second tip, Block Counter (Tip #2015), is simple enough in concept. It counts blocks and reports the number found within a selection window. But what is interesting is that the output can be directed to an Excel spreadsheet. If you are looking for a good example of how this can be accomplished, be sure to download the tip and take a close look at the source code. The approach taken is very direct and a clear example. You must have Microsoft Excel installed on your computer for this utility to create an Excel file, because the function will directly address the Excel application object. Load the LSP file and then type the command Blcx at the AutoCAD Command line to run the function. This is a wonderful tip for Visual LISP programmers looking for a good example of interfacing AutoCAD and Excel.
The third tip from Alexander, Block Corrections (Tip #2016), is a tool for fixing errant references in blocks. An errant reference might be something that is defined to a particular layer and thus does not change based on the insert environment. Although this feature is useful as an example, it is also quite practical, as there are times when you want to fix a block definition so all objects behave according to normal insertion rules -- only to find that it is difficult and somewhat tedious to accomplish. Not any more. Load the LSP file supplied and type the command Btz. Next select how you want the blocks to be updated. The choices are by byBlock, byLayer or Current. Current means that the color attribute is set to the current layer color. All the objects in the definitions of the blocks selected will now be updated so they contain the byBlock, ByLayer or direct color number reference as selected. These three tips from Alexander are great!
Join Them Up
Our last tip for this month is from Andrej Gumula. Intelligent Join (Tip #2017) is used to join lines, arcs and polyline objects into a single polyline. This variation of the Pedit Join command greatly simplifies the work involved, especially when dealing with drawings where overlapping objects can interfere with a less-intelligent join utility. To use this powerful tool, load the LSP file, then type Intellijoin to start the command. Select an initial object so the utility knows which layer the source objects are to be retrieved from. You can add other layers by selecting more objects. Note that the prompts are somewhat confusing at first, but that's because Andrzeg went to great effort to translate them to English for us. If you find this utility useful, you might be tempted to dig into the code and change the prompts to something that make more sense for your specific application. When you are finished selecting the layers for the join operation, the function takes off and zooms around the screen connecting the objects. An excellent tool if you need to work with polylines!
When submitting tips for Hot Tip Harry, please remember that source code must be provided. You also should try not to use any programming tools other than those provided in the standard AutoCAD package. By following these simple guidelines, you increase the chance of your tip being included in Harry's library, and it increases the number of downloads your tip will have from all AutoCAD users.
Thanks to everyone who submitted tips -- and keep on programming!
About the Author: Bill Kramer
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!