June 26, 2012

ACA: Occupancy Load Calculations with a Column Total

In the thread in the Autodesk AutoCAD® Architecture Discussion Group that was the basis for my previous blog article post on occupant load calculations, Ted Evans pointed out that if you add a total to the occupant load column, the sum may not reflect the total of the displayed values. He is correct, if the displayed values have a sufficient number of cases where small fractional amounts were rounded up. Because any fractional amount is being rounded up in this case, there is no opportunity for round ups to be offset by round downs, making the fact that ACA uses the unformatted values when calculating the total even more apparent than in a situation where rounding is done to "nearest".

My reply today explained the reason why the total was not the same as the sum of the displayed numbers, and I indicated that in order for the total to be correct, the rounding should be done within the formula property, rather than by the Property Data Format. [For other options, see this blog article, which includes several means of achieving real number rounding and getting correct column totals.]

By placing the results of each branch of the second If statement in a variable [occs] instead of making it the RETURN value, I was able to then process the value in variable occs. If occs is not a whole number (that is, if subtracting the integer portion of occs from itself does not result in a value of zero), the value of occs is reset to the integer portion of occs plus one. Otherwise, occs is a whole number, and rounding up is not necessary. The revised formula is shown below; a sample file was included in my reply in the Discussion Group.
occLoad = [SpaceStylesCalcs:Occupant_Load]

If occLoad = 0 Then
 doCalc = 0
 occLoad = 1
Else
 doCalc = 1
End If

If doCalc = 1 Then
 occs = [SpaceStyles:BaseArea] / occLoad
Else
 occs = 0
End If

If occs - Int (occs) <> 0 Then
 occs = Int (occs) + 1
End If

RESULT = occs

June 24, 2012

ACA: Occupancy Load Calculations and Division by Zero

A question concerning occupancy load calculations and how to handle Spaces to which an occupant load of "0" has been assigned was posted to a thread in the Autodesk AutoCAD® Architecture Discussion Group. Dividing the Space's area by the occupant load causes an error in the formula when the occupant load is zero. As noted in my response, which includes a sample file done in ACA 2011, a simple If statement cannot be used test for a zero value and then avoid the calculation, because VBScript will evaluate the entire statement, including logical paths that would not be taken, and still end up in an error condition.

My solution was to use a variable (called occLoad in the example) to hold the occupant load property value and two If statements. The first tests for a zero value and sets a variable (called doCalc in the example) to indicate whether or not a calculation should be done. If it finds a zero value, the doCalc variable is set to 0 (do not calculate) AND the occLoad value is changed from 0 to 1. If occLoad is not zero, the first If statement only sets doCalc to 1 (do calculate).

The second If statement then tests the value of doCalc: if it is 1, it returns the result of dividing the area by the occupant load; if it is 0, it returns 0. Because the first If statement assures that the occLoad value will not be zero, the division in the second If statement never results in an error condition, and the desired result for an occupant load of zero is returned.
occLoad = [SpaceStylesCalcs:Occupant_Load]

If occLoad = 0 Then
 doCalc = 0
 occLoad = 1
Else
 doCalc = 1
End If

If doCalc = 1 Then
 RESULT = [SpaceStyles:BaseArea] / occLoad
Else
 RESULT = 0
End If

The example file also shows how a Property Data Format can be used to round any result with a fractional amount up to the next highest integer, since you would want that when calculating occupant loads for egress analysis. It also demonstrates using a style-based Property Set to hold the occupant load property, so that the occupant load value only needs to be added to the Space Style, and not to each individual Space.