3

Query the number of model stories using OpenStudio sdk

I am wondering if it is possible to get the number of stories in a model using the OpenStudio SDK, I thought that I could do this using the standardsNumberOfStories property in the Building class reference.

See: https://openstudio-sdk-documentation....

But it just returns an optional int and to_s or to_i return nothing, I seem to have found a dead end. Is there any way I can query the number of stories from the model using the SDK?

antonszilasi's avatar
1.5k
antonszilasi
asked 2018-11-28 17:48:42 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

building.standardsNumberOfStories just access a field to store optional metadata. It doesn't actually inspect other model elements. There are other options. You could simply do model.getBuildingStorys.size to count story objects, but that may also count building story objects that are not assigned to any spaces. Some other issues are dealing with zone multiplier and plenums/attics. In the openstudio-standards gem there is a model_effective_num_stories method. This addresses many of these issues, and others such as identifying below vs. above grade stories. I believe it does expect spaces to already be assigned to building story objects. If you are working with a generic model that may not have story objects you can use the AssignSpacesToStories measure on BCL which evaluates the z value of floors in spaces, creates a story object for common values, and assign the spaces to the new story.

David Goldwasser's avatar
20.4k
David Goldwasser
answered 2018-11-28 23:14:27 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
1

When an optional value is returned, it may or may not have a value inside it. You need to use special code to retrieve its value if one exists. See the "OpenStudio Measures and the boost::optional Type" section of the Measure Writer's Guide for a good explanation of how to handle this.

In your specific case, the returned value is optional because OpenStudio models can be created that do not have the number of stories specified.

shorowit's avatar
11.8k
shorowit
answered 2018-11-28 21:28:26 -0500, updated 2018-11-28 21:28:48 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments