January 28, 2006

Formatting Areas and Volumes in Schedules Using Drawing Setup

When displaying areas or volumes in a Schedule Table or a Schedule Tag, you could always apply a Property Data Format [login to the Triple D Design Wiki here, then copy this link and paste it into the Address line of the browser window viewing the Wiki for more about Property Data Formats] to get the desired precision and units suffix. And if those settings should always be the same, no matter what drawing an which project is open, then the Property Data Format is the way to go. You might also choose to set up fixed suffixes in a formula property, and could choose between imperial and metric by reading in the value of the MEASUREMENT System Variable, as noted in this blog article. But if you have different units needs in different projects [imperial for some, metric in others] or need to customize the precision or suffix text to suit the requirements of different clients, you would need to rework your Property Set Definition[s] for each unique case and apply a different Property Data Format to the area and volume properties.

You may have noticed that the Units tab of the Drawing Setup dialog has a place to choose the Type, Precision and Suffix for both area and volume. ADT will report the area and volume values in an automatic property using the Type selected, but the Precision and Suffix are determined by the Property Data Format. You can, however, make use of the Precision and Suffix entries by using a formula property. You can read in these settings, then use a formula to apply the desired format. Special thanks go out to Tony Burba, for helping me find the right place to look for these properties in a thread in the Architectural Desktop Customization Discussion Group.

I have posted two sample files that were done in ADT 2006 to a thread in the Architectural Desktop Content Discussion Group. I chose a modular approach, with separate formulas for the Precision, Suffix and formatted value to display in a Schedule Table or Tag. If you prefer to limit the number of properties to make it easier for a user to find the manual ones when editing property data, you could just as easily have one formula for area and one for volume that read the desired precision and suffix values, storing them in variables, then using the variables to supply the values to the formatted RESULT. The formulas are in the AllObjects Property Set Definition, which is set up to apply to, strangely enough, all objects. The following discusses the properties used for the area value; the volume properties are similar.

The AreaUnformatted property is an automatic property that has the Area [or similar] property checked for all object types that have an area-type property available. I did this by checking the Area property under 3D Face, which will also check all of the other properties whose title is exactly "Area". Then I scrolled down the list and, while holding down the CTRL key, checked off other area-type properties for objects that did not have an "Area" property, such as "Base Area" for Area objects. A Property Data Format called "Standard-8" is applied to this property. Standard-8 is a copy of the out-of-the-box Standard Property Data Format, with the precision set to eight decimal places to get the maximum number of decimal places passed on the the formatting formula.

The AreaPrecision property is a formula property that reads the value set for precision on the Units tab of the Drawing Setup dialog, using the following formula:
Set acadApp = GetObject(,"AutoCAD.Application.16.2")
Set adtApp = acadApp.GetInterfaceObject("AecX.AecArchBaseApplication.4.7")
RESULT = adtApp.ActiveDocument.Preferences.AreaPrecision

Thanks also go out to Jimmy Bergmark for the tip on how to show long lines of code, posted to his JTB World blog.

The formula for the AreaSuffix property is similar to the AreaPrecision property formula, with a change to the referenced item:
Set acadApp = GetObject(,"AutoCAD.Application.16.2")
Set adtApp = acadApp.GetInterfaceObject("AecX.AecArchBaseApplication.4.7")
RESULT = adtApp.ActiveDocument.Preferences.AreaSuffix

The AreaFormatted property is the formula property that pulls it all together. The VBScript FormatNumber function is used to apply the desired precision and covert the number to a string to which the AreaSuffix value is concatenated.
FormatNumber([AreaUnformatted], [AreaPrecision], -1, 0, 0) & "[AreaSuffix]"

The application references shown above and in the sample file will work for ADT 2006 only. You can use these formulas in ADT 2004 or 2005 by changing the numbers as follows:
16.2 in 2006 becomes 16.1 in 2005 or 16 in 2004.
4.7 in 2006 becomes 4.5 in 2005 or 4 in 2004.

I also tossed in a ObjectType automatic property to have something in the sample Schedule Tables to link the sample object to the listed areas and volumes. In a real schedule, you probably have a identifcation number or some other means of showing what object is referenced on a given line and would not need this property.

If you open the imperial units sample file, you will find the Units settings match those in the image above, and the Area Schedule looks like this:

Now change the settings for area units on the Units tab of the Drawing Setup dialog. I chose to use the settings shown below.

Update the Schedule Table, and you will find that the precision and units of the area values have changed according to your revised settings. For the example above, the Area Schedule now looks like this:

The AecArchBaseDatabasePreferences object gives access to a number of ADT settings. You can see the full listing in the Help. In 2006, expand the following on the Contents tab:
Architectural Desktop 2006 Help
>Architectural Desktop ActiveX Reference
>>AEC Architectural Automation Reference
and then select the AecArchBaseDatabasePreferences Object.

There are quite a few settings in there that could be useful in a formula property for other scheduling "opportunities". If you hit upon a good one, be sure to share it with the community by posting a sample file in the Autodesk Architectural Desktop Content Discussion Group.

No comments: