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

Error when ''applying measure now'' in OpenStudio

asked Nov 21

AvgStudent's avatar

updated Nov 22

Hi, I am re-writing a measure from my professor's former student and I am having issues while trying to open the updated measure in OpenStudio.

First, the OpenStudio ''Apply measure now'' window shows an error saying that it failed to show the measure's arguments. When looking at the metadata file (.xml) the second line of the file shows this error: <error>Failed to infer measure name from 'C:/Users/[path_to_measure]/measure.rb'</error>

There is also a single argument in the .xml file, called ''space_name'', while my measure calls for about 17 arguments.

When I try to update the .xml file using the OpenStudio CLI in the command promp, the error specifies that the error occur when I query the model to find the available AirLoopHVAC [model.getAirLoopHVAC] in order to build a choice argument. Note that the list created by the query is not implemented as an argument itself, only the user-selected loop is used as an argument. According to chatGPT, you shouldn't be able to query information in the ''arguments'' method. However, the measure created by the previous student used this method and it works without any issues.

The measure is written in Ruby.

What can I do to solve this problem?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered Nov 21

updated Nov 22

I might be totally misunderstanding your question but...

There is no model.getAirLoopHVAC. All methods to return model objects, for which there can be more than one, are like model.getWhateverObjects (note the "s" on the end) and return an array of objects. So if you wanted a list of AirLoopHVAC names, you could do:

air_loop_hvac_names = []
model.getAirLoopHVACs.each do |air_loop_hvac|
  air_loop_hvac_names << air_loop_hvac.name.get
end

or in a one-liner:

air_loop_hvac_names = model.getAirLoopHVACs.map{ |air_loop_hvac| air_loop_hvac.name.get }
Preview: (hide)
link

Comments

It looks like that was the problem. I'm a beginner using Ruby and programming measures for OpenStudio and I would appreciate if you could point out where this information is shown. At the moment, I am referring myself to the EMS Application Guide and the OpenStudio Measure Writer's Reference Guide. While the examples show the added ''s'' at the end of model.get statements, the Writer's Reference Guide doesn't clearly specify that it is required. Are there any other resources that could help me understand the various functions for writing measures? Thank you

AvgStudent's avatar AvgStudent  ( Nov 22 )
1

There's a bit in the Measure Writer's Reference Guide (under Measure Writing):

"spaces = model.getSpacesretrieves all the spaces in the model, and stores them in an array called spaces. Measure authors can use this syntax to retrieve a vector of many objects from a model (e.g.,.getThermalZones, .getSpaces, etc.)."

Denis Bourgeois's avatar Denis Bourgeois  ( Nov 22 )
1

SDK docs are likely a must - a resource newbies may need to revisit. I'd also suggest OpenStudio-Resources simulation tests - nice concise examples of API-based scripts, in both Ruby and Python.

Denis Bourgeois's avatar Denis Bourgeois  ( Nov 22 )

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: Nov 21

Seen: 178 times

Last updated: Nov 22 '24