PDA

View Full Version : Property Set Definition Formula for Occupant Load Schedule



t.scibilia
2016-04-11, 07:01 PM
Hey, I'm trying to create a property set definition formula to calculate the occupant load for a group of rooms. I created two new property set definitions: one is for the user to input the building code "occupants per sf" and one for "occupancy per equipment". In some rooms we design the occupant load based on the design (not a prescribed value).

The goal is to have a column in the schedule to output the number of persons permitted.
I would like to create a formula that looks to the "occupants per sf" property definition first; if the user entered "0" then the formula would display the number from the "occupancy per equipment" property definition. Otherwise if the "occupants per sf" property definition is anything other than "0", the formula would calculate the "net area" / "occupants per sf".

The problem is I can't get it to calculate correctly using if...then...else statements
I can only get the formula to calculate one formula. it works when I type "if...then" but as after I type an "else" statement, the sample result just displays the formula (it doesn't calculate the answer).

This part works:

If [OccupancyPerSF]=0 Then RESULT=[OccupancyPerEquip]

This is what I want, but have a problem with the calculation:

If [OccupancyPerSF]=0 Then RESULT=[OccupancyPerEquip] Else RESULT=[SpaceStyles:NetArea]/[OccupancyPerSF] End If

CAtDiva
2016-04-11, 08:12 PM
Hey, I'm trying to create a property set definition formula to calculate the occupant load for a group of rooms. I created two new property set definitions: one is for the user to input the building code "occupants per sf" and one for "occupancy per equipment". In some rooms we design the occupant load based on the design (not a prescribed value).

The goal is to have a column in the schedule to output the number of persons permitted.
I would like to create a formula that looks to the "occupants per sf" property definition first; if the user entered "0" then the formula would display the number from the "occupancy per equipment" property definition. Otherwise if the "occupants per sf" property definition is anything other than "0", the formula would calculate the "net area" / "occupants per sf".

The problem is I can't get it to calculate correctly using if...then...else statements
I can only get the formula to calculate one formula. it works when I type "if...then" but as after I type an "else" statement, the sample result just displays the formula (it doesn't calculate the answer).

This part works:

If [OccupancyPerSF]=0 Then RESULT=[OccupancyPerEquip]

This is what I want, but have a problem with the calculation:

If [OccupancyPerSF]=0 Then RESULT=[OccupancyPerEquip] Else RESULT=[SpaceStyles:NetArea]/[OccupancyPerSF] End If

Which software are you using (looks like it's AutoCAD Architecture)?

dkoch
2016-04-13, 05:06 PM
AutoCAD Architecture is going to evaluate the entire formula, not just the logical branch that would be evaluated for a given case. So, when [OccupancyPerSF] is set to 0, even though only the true condition would need to be evaluated, the false (Else) condition will also be evaluated, and that will result in division by 0, which causes the formula to fail.

You will want to use something like this, which makes the same test, but avoids division by zero:

If [OccupancyPerSF] = 0 Then
occPerSF = 1
Else
occPerSF = [OccupancyPerSF]
End If

If [OccupancyPerSF] = 0 Then
RESULT = [OccupancyPerEquip]
Else
RESULT = [SpaceStyles:NetArea]/occPerSF
End If

You could also choose to always have a non-zero value in [OccupancyPerSF] (make the default value 1 and instruct users never to set it to 0) and make your test based on whether OccupancyPerEquip is zero or not. If it is zero, then set the result to [SpaceStyles:NetArea]/[OccupancyPerSF], otherwise, set it to [OccupancyPerSF].

Note that the above does not apply any rounding; I would expect an occupant load calculation to always round any fractional amount up to the next whole number. The following builds on the previous, and rounds up any fractional amount when [SpaceStyles:NetArea]/[OccupancyPerSF] is calculated.

If [OccupancyPerSF] = 0 Then
occPerSF = 1
Else
occPerSF = [OccupancyPerSF]
End If

If [OccupancyPerSF] = 0 Then
RESULT = [OccupancyPerEquip]
Else
occTotal = [SpaceStyles:NetArea]/occPerSF
occTotalWhole = Fix( occTotal )
occTotalFract = occTotal - occTotalWhole
If occTotalFract > 0 Then
occTotal = occTotalWhole + 1
Else
occTotal = occTotalWhole
End If
RESULT = occTotal
End If

Also, make certain that the [SpaceStyles:NetArea] value does not have a Property Data Format that adds any text, such as a " SF" suffix. You do not have to alter the [SpaceStyles:NetArea] property itself; in your formula property, in the Sample Values area, you can specify a different format, such as Standard, that does not add text to the numeric value in a prefix or suffix.