[Click Here for Info on Placing Your Banner Ad Here]
CLICK ON THE IMAGE TO FIND OUT HOW TO PLACE YOUR AD WITH PAUG

Attredef.lsp

I am sure that you all know very well how to update all occurrences of a block in your drawing by using the BLOCK command to redefine the block. However this technique updates only graphic entities - it does not update any attributes that you have assigned to the block.
June's Command of the Month will show you how to load and run the AutoLISP file ATTREDEF.LSP. This LISP routine is a standard "free-bee" with AutoCAD and is located in the support directory under the common directory and will redefine both, block graphics and the block attributes.
To load the AutoLISP code from ATTREDEF.LSP into your drawing editor, select the Applications command from the Tools Pulldown. When you do, you will see the Load AutoLISP, ADS and ARX files dialogue box. Click on the file button, this will allow you to select a LISP file from your hard drive. AutoCAD will display the Select AutoLISP, ADS or ARX file dialogue box. Locate and select the ATTREDEF.LSP file, double click on the file or highlight it and click on OK, this will select the file and add it to your current selection of "PiX".
At this point, AutoCAD will return you to the Load AutoLISP, ADS and ARX files dialogue box but this time the file ATTREDEF.LSP will be at the top and highlighted in the Files to Load list box, click on the Load button to load the routine into memory.
The LISP routine will indicate it is loaded by prompting that the routine can be invoked by typing in ATTREDEF or AT at the command prompt. Also, if you had a check mark in the Save List check box, the ATTREDEF.LSP code will permanently added to the list of Files to Load.
When you use ATTREDEF.LSP to redefine blocks containing attributes, the resulting block will contain only those attributes that have been named in the new definition. To understand how ATTREDEF.LSP affects attributes, you will need to examine the three text fields, Tag, Prompt and Value; that each attribute contains. When you first create an attribute to place in a block, you will need to assign values to each of these fields. You can do this several different ways, one way is to use the DDATTDEF command and enter information in a dialogue box. The Tag field contains the attributes name, or identifier. Here you might enter values such as COST or the NAME of a part. The Prompt field contains a prompt for AutoCAD to display when inserting a new copy of the block. In the Value field you will enter a default value such as a dollar amount, a quantity or a weight, the Value field should have a value that is in a direct relation to the Tag field.

(EXAMPLE)

This is a typical anchor bolt, it has three attributes assigned to it. When the block is exploded, you can see the values assigned to each attributes Tag field, each of these Tag fields have values assigned to the default Value field. For this exercise, the CAD Operator is selecting the part from a pull down so no Prompts are required just the data that is important to the part is required. For the Tag "ANC-BOLT" the Value is it's diameter, length and the hooks length, the Tag "COST" has a numeric Value that is the price per part and the "QTY" Tag has a default Value of the numeric (1). To modify attributes located in the block, first insert the block 75x12x3 "exploded" and use the DDATTDEF command to add a new attribute, we will add an attribute that contains the weight of each part. Now we will use ATTREDEF.LSP by typing in ATTREDEF or AT at the command prompt and then entering the block name of 75x12x3. You will now need to pick the graphic entities as well as the attributes that make up the block. Finally, select the insertion point - if you intend your attributes to be visible, you will need to use the same insertion point as the previous made block, I use "tether lines" to do this - and touch the enter key. As soon as you touch the enter key, all of your blocks are updated showing the modified attribute(s).


Command of the Month: Main
Command of the Month: 1999 | Command of the Month: 1998 | Command of the Month: 1997

Jan 97 | Feb 97 | Mar 97 | Apr 97 | May 97 | Jun 97 | Jul 97 | Aug 97 | Sep 97 | Oct 97 | Nov 97 | Dec 97


If you have any questions, comments, or suggestions about the Command of the Month,
please send e-mail to mail@paug.org.