Tips From Our Readers15 Aug, 2004 By: Bill Kramer
Control your layers, date your drawings, and more.
First event up in the Tip Olympics is layer control. Everyone has a better way of doing layers. That?s what makes them great?they?re so adaptable. Of course, that means you need to be able to track them. That brings us to Get Object Color Relationship (Tip #1968) from Walt Bedinger. This utility lets you check the color and layer relationship for entity objects. After loading the function, type Getcolor at the Command prompt and select an object in the drawing. A prompt appears with the object?s color and layer assignments. This is a friendly function that lets you know if a color assignment is by block, layer, or the object. It also clearly demonstrates how the color code and layer name system are used in entity data lists.
Theodorus Winata?s Copy to Layer (Tip #1969) lets you select a layer name from a dialog box. After you pick the layer name, an object selection prompt appears for objects to be copied. You can select multiple objects. Next the routine requests a base point plus displacement point. It copies the selected objects to the new location with the layers changed. Combining multiple steps into a single command is what it?s all about. Excellent tip!
The leader in complexity for the layer events is Layer Display Suite (Tip #1970) from Rechen Nan. This suite of commands is supplied as a pair of files zipped together. Unzip the files and place the LSP and DCL files in the standard AutoCAD search path. Once the LSP file is loaded, you can select from six commands that control the display of layers (by hiding or showing them). The commands in this suite are:
- Ho: hide selected objects
- Show: show all objects
- Hexp: hide all objects except those selected
- Sbl: show objects on layers selected
- Hbl: hide layer based on object selection
- HBLE: hide all objects except those on layers of selected objects
Simple Wins the Prize
As you know, an elegant and simple combination of commands to accomplish a task is often best. Date Stamp (Tip #1971) from Leonid Nemirovsky is a great example of this concept. The date stamp program (type DST after loading the LSP file) asks for a location, then inserts the current drawing name, along with the date and time the drawing was last saved. This routine takes advantage of the field feature in text inside AutoCAD 2005, resulting in a short and succinct function. It won?t work with earlier releases of AutoCAD.
Quick Area (Tip #1972) from Bryan Bobrick provides a quick answer to the question: What is the area of that object? After the LSP file is loaded, start the Quickarea command. The function prompts you to select a closed object such as a circle or a polyline. After you select the object, the routine executes the Area command and shows the value in the AREA system variable. Quickarea displays the value from the system as square feet and other units of measure, although you may be using different units. This function is a great example of how to exploit information inside AutoCAD with AutoLISP.
Watson Kilbourne supplies us with another hatch pattern, Arched Tiles (Tip #1973). This hatch pattern looks like a tiled roof. Watson?s genius for patterns knows no parallel. This one makes you want to start tiling every roof.
The Countdown Begins!
Harry reminded me that we?re in the closing stretch for the $1,000 grand prize in our own Code Olympics. Some readers have contributed great code so far, but it?s not over yet. Visit the Cadalyst web site and send us your best work to review for inclusion in Hot Tip Harry?s library.