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

OpenStudio SDK model.runPeriod within interactive ruby console

asked 2016-12-28 14:39:32 -0600

antonszilasi gravatar image

updated 2017-01-03 10:10:15 -0600

Dear all,

I am quite confused how to use the OpenStudio SDK within the irb console. I have successfully run the code written by mdahlhausen in his answer here

In the command line when I call the model's run period, I am now getting:

image description

However whenever I try one of the methods listed under RunPeriod class seen here

such as

image description

Ruby tells me that the method is undefined. What I am I missing here?

Furthermore how can I display all the methods in the runPeriod class within the irb console? .methods called on the runPeriod class return what seems to be very generic methods see:

image description

While all the methods listed within the OpenStudio SDK are returned on the model class

Any insights would be most appreciated!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-29 10:09:08 -0600

updated 2016-12-29 10:12:18 -0600

model.runPeriod returns an optional type. To get the actual RunPeriod object you first need to check if the object is 'empty' (see the 'OpenStudio Measures and the boost::optional Type' section here). So for instance:

run = model.runPeriod.get if not model.runPeriod.empty?

will return an object of class OpenStudio::Model::RunPeriod if the osm has a run period object, or false if it doesn't.

Once you get the actual object, running the methods method will show the full list of methods for that object.

edit flag offensive delete link more


This is by far the most annoying part of the OpenStudio SDK. Necessary perhaps, but ultra-annoying.

__AmirRoth__ gravatar image __AmirRoth__  ( 2016-12-29 10:28:41 -0600 )edit

I nominate this as most annoying, but fortunately it is pretty rare :). This is one of a few objects that take an optional double for set methods. So you have to make an optional double from a double to set a value.

@antonszilasi good question, but you may want to rename it to be more specific about the error you were seeing.

David Goldwasser gravatar image David Goldwasser  ( 2016-12-29 11:24:14 -0600 )edit

Your Answer

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

Add Answer


Question Tools



Asked: 2016-12-28 14:39:32 -0600

Seen: 206 times

Last updated: Jan 03 '17