Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Query the number of model stories using OpenStudio sdk

asked 2018-11-28 17:48:42 -0600

antonszilasi gravatar image

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?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-11-28 23:14:27 -0600

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.

edit flag offensive delete link more

answered 2018-11-28 21:28:26 -0600

updated 2018-11-28 21:28:48 -0600

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Question Tools

1 follower


Asked: 2018-11-28 17:48:42 -0600

Seen: 132 times

Last updated: Nov 28 '18