Creating a formula that returns valid data can be a complex task. As the following example shows, you can simplify the process by using the Formula Property Definition worksheet to construct the formula with VBScript Code. You then insert sample values into the formula and evaluate the result.
The space object has a single numeric value for its height, which is adequate for the majority of spaces in a room schedule. However, to get more control over how space heights are displayed for rooms without flat ceilings, you can create a formula that returns a text override, such as “Vaulted” for a cathedral ceiling, or return the actual height. The completed worksheet for such a formula is shown below.
Using primarily the default property set definitions in the Style Manager, the following process was completed.
Added SpaceStyles as a new property set definition
On the Definition tab for the SpaceObjects property set definition
Edited the HeightDisplayed formula property definition on the Formula Property Definition worksheet
As you make changes to the formula, you can view a sample result. For example, entering the formula “2+3” displays “5” in the Sample Result pane. This lets you correct a formula that fails to evaluate as expected.
When a property definition is first inserted in a formula, its sample value is taken from an object in the current drawing that uses the formula’s property set definition or from a default object.
When you move the cursor over an item, a tooltip displays the text that appears in the formula when it is inserted.
After you add VBScript code to the formula, red or gray text may be inserted to help construct the formula. Red indicates fields where additional code must be added. To remove a red field, select it, and enter text, insert a property definition, or insert other VBScript code.
Gray fields surrounded by brackets indicate optional fields. Typing anywhere within the gray brackets, or deleting one bracket, will remove the brackets and convert the code from optional to required.
You can save a formula containing red and gray fields for future editing, but a warning dialog box displays because the formula will not be evaluated correctly. You can access online Help for VBScript code in the formula for more information on its proper usage.
Every time a sample value is changed a new sample result displays.
Sample values are formatted and inserted into the formula in place of the corresponding property definition names with brackets surrounding them. The entire sample formula is evaluated, and the result displays in the Sample Result pane.
Because this formula contains the word RESULT, it is evaluated as a function instead of an expression, and the value of the formula property is the last value assigned to RESULT. The result of this valid formula is Vaulted.