Showing posts with label Field. Show all posts
Showing posts with label Field. Show all posts

Monday, October 6, 2008

Exploring AutoCAD Field Capabilities by Developing a Simple Field Calculator

We extensively use FIELD object these days for several purposes like creating a custom plot stamp or printing the filename in the title block etc. When we dig in depth, FIELD object will provide us with a lot of possibilities. Here is a simple calculator application using the 'Formula' inside the 'Object' category of field.

We are going to develop the calculator as an attributed block reference where you can modify the attribute values to get the result in another attribute. For this purpose, create on block with attributes FIRST_NUMBER,OPERATOR,SECOND_NUMBER and RESULT attributes and insert it into the drawing.

Insert the block and edit attributes in the Edit Attributes dialog. Leave the first three attributes as we are not going to do any field operations over there. Right click on the last attribute (RESULT) and select 'Insert Field' option as shown in the picture.


You will be provided with field dialog box. Select 'Objects' field category and choose 'Formula' from the field names. Now right click on the 'Formula' text box and choose 'Insert Field' option once again (See the picture).



Now an additional field dialog will show up. This time select 'Object' field name from the 'Objects' category. Select the inserted block using the small button located near the 'Object type' text box. Once selected, the block properties including the attributes will be shown up in the properties list box. Select the FIRST_NUMBER attribute from the list and click 'Ok'.



Repeat the steps 3 and 4 to include the attributes OPERATOR and SECOND_NUMBER in the formula text box as shown in the picture. That's it. Press ok to finish the procedure.


Try changing the FIRST_NUMBER, OPERATOR and SECOND_NUMBER values. if the FIELDEVAL system variable is properly set, you will see the result soon after the next regen.

If you want to know how to create 'Live Fields' inside a drawing, see the AutoClock post.