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

OpenStudio Measure with long list of inputs -- best practice

asked 2023-12-05 10:29:30 -0500

jugonzal07's avatar

updated 2023-12-07 09:21:14 -0500

I'm writing an OpenStudio measure with a long list of options for many of the input parameters. Initially, I tried to use a secondary file to host all the constants to keep things tidy but found importing parameters into the measure.rb file resulted in the OpenStudio application not populating my input dropdowns (although I could see them in the measure.xml ?) So I tried looking through other measures and found most folks just kind of listed them all out in the measure.rb file. Is there no better best practice?

MCVE directories for a working and broken example of what I mean can be found here:

You will see both measures populate the choice argument with a module called MyConstants:

choices_os_vector = OpenStudio::StringVector.new
option_list = MyConstants::CHOICE_LIST
option_list.each do |option|
  choices_os_vector << option
end

The only difference is that working example has the module inside the measure.rb file while the broken example references the module from a separate file called my_choice_constants.rb.

I would much rather have this list of inputs reference a dynamic reference that updates with something like the OpenStudio Standards gem rather than have to update it in two places.

edit retag flag offensive close merge delete

Comments

More interestingly, can you please make a Minimum Complete Verifiable Example (MCVE) for the "Initially, I tried to use a secondary file to host all the constants to keep things tidy but found importing parameters into the measure.rb file resulted in the OpenStudio application not populating my input dropdowns" so we can try to reproduce / see if we can fix it?

Julien Marrec's avatar Julien Marrec  ( 2023-12-06 17:52:55 -0500 )edit

Thanks Julien, the MVCE has been uploaded and the question updated to reflect it. Let me know if that is more in line with what you were thinking.

jugonzal07's avatar jugonzal07  ( 2023-12-07 09:21:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2023-12-08 05:30:44 -0500

updated 2023-12-11 03:26:39 -0500

A measure must follow a given structure. Your broken example does not follow the expected convention.

In a measure, the only top-level allowed files are:

  • measure.(rb|py|xml)
  • README.md, README.md.erb
  • LICENSE.md

Only these subfolders are approved:

  • docs
  • tests
  • resources

Anything outside of that is NOT copied.

This is actually documented properly: https://nrel.github.io/OpenStudio-use...

So place my_choice_constants.rb at resources/my_choice_constants.rb and adjust the require clause, and you should be good to go.

edit flag offensive delete link more

Comments

Thanks so much! I knew there were mandatory files but failed to realize resource files must follow a strict convention as well. This will keep things much tidier, thank you.

jugonzal07's avatar jugonzal07  ( 2023-12-08 10:45:08 -0500 )edit

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

1 follower

Stats

Asked: 2023-12-05 10:29:30 -0500

Seen: 309 times

Last updated: Dec 11 '23