Area Field to Attribute

See also Length & Area Field.

Function Syntax A2A
Current Version 1.2
Download Areas2AttributeV1-2.lsp
View HTML Version Areas2AttributeV1-2.html

Program Description

This program allows a user to populate a selected attribute with a Field Expression referencing the area, or sum of areas, of one or more objects.

Upon issuing the command syntax A2A the user is prompted to make a selection of objects for which to retrieve the area; if more than one object is selected, the cumulative area for all objects will be displayed by the resultant Field Expression.

Following object selection, the user is then prompted to select either an attributed block or an attribute in which to house the Field Expression. If the user directly selects an attribute, the attribute value will be populated with the Field Expression; if the user selects an attributed block containing more than one attribute, the program will prompt the user via a dialog interface to choose an attribute tag to be populated with the Field Expression.

An optional attribute tag parameter specified at the top of the program source code also allows the user to predefine the attribute tag that is to be populated with the Field Expression. If this parameter holds a valid string value, the program will automatically populate such attribute following selection of an attributed block containing an attribute with a matching tag name.

The Field will display the sum of the areas of the selected objects, formatted using the Field formatting code specified at the top of the program.

Area Format

The field formatting code indicated at the top of the program source code (line 25) may be altered to display the area in a desired format:

(setq fmt "%lu6%qf1" ;; Field Formatting

To determine the correct formatting code to be used, perform the following steps:

  • Type FIELD at the AutoCAD command-line and press ENTER to open the Field dialog.
  • Select Objects from the 'Field Category' drop-down menu.
  • Select Object from the 'Field Names' section.
  • Select an object (with area) from the drawing by clicking the object selection button adjacent to the 'Object Type' box.
  • Select the Area property from the 'Property' panel.
  • Configure the formatting options as desired.
  • Click OK and pick a point in the drawing to create a temporary MText Field.
  • Download & load my Field Formatting Code program.
  • Type fieldformat to run the program and select the temporary MText Field created earlier.
  • Following a valid selection, the field formatting code will be printed to the command-line, e.g.:
  • Formatting code: "%lu4%ds44%th39"
  • Copy the formatting code (including the quotation marks) to the program source code where noted:
  • (setq fmt "%lu4%ds44%th39" ;; Field Formatting
  • Save and load the modified program file.

See also Length & Area Field.

Instructions for Running

Please refer to How to Run an AutoLISP Program.


increase · reset · decrease

Designed & Created by Lee Mac © 2010