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

OpenStudio SDK model.runPeriod within interactive ruby console

asked 8 years ago

antonszilasi's avatar

updated 8 years ago

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 8 years ago

updated 8 years ago

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.

Preview: (hide)
link

Comments

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

__AmirRoth__'s avatar __AmirRoth__  ( 8 years ago )
2

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's avatar David Goldwasser  ( 8 years ago )

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

2 followers

Stats

Asked: 8 years ago

Seen: 293 times

Last updated: Jan 03 '17