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

Iterating through OpenStudio Objects to get their "Types" and "Attributes"

asked 2022-11-17 10:53:43 -0500

updated 2022-11-17 16:37:52 -0500

Hi All,

For context this is being done using Python. I'm trying to see if there's a built-in method where I can load an existing OpenStudio model, use specific_object = osm.getObject(an_object_handle).get() to isolate a specific object (where osm is the whole model), and then pick apart and inspect what's in the object. If I use print(specific_object) I get a nice human-readable block of text. However I can't seem to figure out how to iterate through these fields beyond just

I'd like to iteratively return if possible the type of object (Space, Thermal Zone, Construction, etc.), and its attributes. Like in the case of a space, returning Space Type Name, Default Construction Set Name, Default Schedule Set Name, etc.

I put types and attributes in quotes in the title because I think the nomenclature in OpenStudio is a little different which might be part of my problem.

I really appreciate any suggestions you all might have. I think if all else fails I could use str(specific_object) to get that human-readable output and then parse through that with other python tools. I just wasn't sure if there was a built-in way. My end goal for this project is to generate some reporting for myself about the model so I don't necessarily need to hang onto the OpenStudio objects themselves nor am I necessarily trying to change them. However, it would be nice to know what options I have should I want to later.


edit retag flag offensive close merge delete


I'm having a very similar issue. In python lots of objects can have their attributes described by object.__dict__ but that has not been implemented here and it's frustrating.

clima337's avatar clima337  ( 2023-10-19 13:33:17 -0500 )edit

I think a wrapper model is probably needed. Something that takes the openstudio module and provides added context and documentation for the functions and objects. You could subclass the objects and then add documentation and description. It's not a small undertaking by any stretch but may be the best way to pythonify the openstudio module.

GFlechas's avatar GFlechas  ( 2023-11-03 16:54:02 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-12-05 22:45:25 -0500

updated 2022-12-06 09:15:20 -0500

I totally misread your question; I am leaving my original answer below just because I had fun figuring that out.

You are looking for the OpenStudio SDK. Take a look at the documentation for the FanOnOff class. There are different methods to get everything about the fan, take a look at the example code below where I print the fan pressureRise parameter.

from openstudio import model
m = model.Model()
f = model.FanOnOff(m)
pressure_rise_si = f.pressureRise()
print('The fan Pressure Rise in Pa is ' + str(pressure_rise_si))


The fan Pressure Rise in Pa is 300.0

You can get any parameter from a fan using similar methods, take a look at the SDK for the specific documentation.

---- Original answer

Hmm interesting, I would like to ask you back what is the reason why you would do this. The following Python code should do what you are asking if I understand what you want to do.

# Create a fan
from openstudio import model
m = model.Model()
f = model.FanOnOff(m)
#  Get the fan iddObject
obj = f.iddObject()
fields = obj.numFields()
for i in range(fields):


Fan On Off 1

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



Asked: 2022-11-17 10:53:43 -0500

Seen: 137 times

Last updated: Dec 06 '22