Hot Tip Harry: Tips from Our Readers -- November 20067 Nov, 2006 By: Bill Kramer
This month, find tips to help you edit text, work with layers and properties, and more.
The first tip, Text Match (Tip #2160) from Chad Douglas, is a relatively straightforward text manipulation tool. Load the LISP code and type MT to activate the command. MT first asks you to select a text object that serves as a source. Additional text selections while MT is still running result in the source text being duplicated at the location selected. This is a nice demonstration of how easy it is to build a power tool for text manipulations -- a tip of the hat from Harry for this nice programming.
Jay Thomas supplied Layer Script Maker (Tip #2161) for moving layer assignments from one drawing to another. This is a clever application that combines two different programming tools, AutoLISP and Scripts. A script file is a sequence of commands to be run by AutoCAD. You start scripts by using the Script command. Jay's tip involves two steps. In the first step, load the LISP code and run it by typing Lyrmak. This collects the layer information in your drawing and creates a script file that you name. The script contains the command sequence that recreates the layer details in a new drawing. For the second step, start a new drawing and type Script. Select the script file (extension SCR) created in the first step and within seconds, the new drawing's layers are the same. Combining the tools is a great way to get things done!
And now for something completely different -- LISP as a tool for creating art. QJ Chen sent Foliage (Tip #2162), which is made up of two function sets. There are three functions named TREE1, TREE2 and TREE3 that draw leaves and trees based on fractal algorithms. Load the LISP code and type TREE1, pick a starting point and then supply a number to seed the fractal. Each number option represents a different variation in the tree growth rules and you'll need to experiment with them to see if anything useful is created. Some result in trees that stand up straight while others look windblown. The result is interesting, and a study of the code is worthwhile for those learning how to program in LISP.
Michael Kolomiyets provided Word Wrap Editor (Tip #2163), a text data-manipulation power tool that works very well. This tool lets you select a group of text objects and force them to fit into a particular column size. If the column size is smaller than the text strings selected, they are wrapped at the spaces to fit. When a larger column size is input, the text strings are combined to fill the space. It's a very useful tool when building tables and bills of materials that lets you get the text input and then edit it into position. Tip #2163 is this month's tip of the month. Thanks, Michael, from everyone who can use this power tool.
Delete Similar Objects (Tip #2164) from Michel Chayer is another power editing tool. After loading the LISP code, type EFS at the AutoCAD Command prompt to start the function. Selecting an object means that all other objects that match in type, layer, line type, style or name are also deleted. For example, if you have a drawing with multiple arcs located on a specific layer, picking any one of the arcs while this command is active removes all of them. This code is very compact and well written -- it's worth examining in detail if you are learning about the manipulation of objects such as hatch and dimensions. Merci, Michel!
Chaining things up is frequent Hot Tip Harry contributor Jay Thomas with Chain Line (Tip #2165). This function draws chain links, as defined by a pair of blocks that are included in the download and must be located in the AutoCAD support folders. After loading the associated LISP code, type Chain to start the action. Jay set the defaults that work best for him, but you can change the code or select the options keyword to override his default settings. The settings include the scale size of the chain figures and whether to start with a face or edge in the link sequence. As you enter points, the chain lines are drawn automatically. For those wanting to know how to incorporate blocks into their line drawings, this is an excellent example from which to learn. Thanks again, Jay.
Riddle Me This (Tip #2166) is a fun utility supplied to us by Edward Boesenberg. Edward named the utility Joke; however, you could substitute various learning tips and tricks for your AutoCAD operators by simply editing the data file provided in the download. The data file must be located in the AutoCAD support path for the function to run. When loaded, type Joke and a riddle is presented in a dialog box. Press the only button to see the answer. Nothing fancy, but some of the riddles are pretty funny. Thanks, Edward, for a tip to the fun side of programming.
Mirrored Save (Tip #2167) from Mohmed Zuber Shaikh is a utility that creates an additional copy of the current drawing on disk for archiving purposes. Load the LISP code and type Mrsave to run the command. You are prompted for a filename in a dialog box. The filename is saved a second time with the name MIRROR concatenated to the filename. Substitute that data in the source code with a network drive or other location for your archive, and this utility can result in drawings being simultaneously saved in more than one place. If you have ever lost a hard drive full of drawings, the value of this utility is obvious. If not, try not to have nightmares worrying about it.
Harry needs your tips! Tips are now tested using AutoCAD 2007 only. Your tip must be able to run in regular AutoCAD and must be supplied in its entirety. To make sure your tips are accepted, confirm there aren't any missing functions (such as library functions), don't use LISP reserve words as variables and be sure to include all source code. Otherwise, all tips are welcomed with open arms.
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!