cadalyst
AutoCAD

Tips From Our Readers

15 Aug, 2004 By: Bill Kramer

Control your layers, date your drawings, and more.


GET THE CODE
Download free code for this and all articles. Look for AUG04.exe in Get the Code.

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. E-mail your tips and tricks to harry@cadalyst.com.

As I walked out of a café in Athens, Greece, I noticed the sun shining brightly off a little car. Who was leaning against it? Harry, of course. ?Ever seen one of these?,? he asked. ?Little sucker gets 100 kilometers to the liter.? I wasn?t sure how he fit into it, let alone the ton of tips he carries around with him. I didn?t have to ask what Harry was doing in Athens. There on the car seat was an envelope marked Olympics. Harry said, ?That?s for your readers?some great stuff once again.?

Layer Control
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
How useful is a function set like this? That depends how many layers you have.

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.


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!