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

Revision history [back]

OS Measure - Building Story

All; Thanks in advance for your assistance. I am a novice when it comes writing both with Ruby and OS Measures, but I am running head-long into it. So, this is really a two part question. First, I am working/playing with writing a measure to rename spaces based on the Building Story, but am having issues. The segment of code that is giving me fits is this: #get model objects spaces=model.getSpaces story=model.getBuidlingStorys

#reporting initial condition of model
runner.registerInitialCondition("The building has #{spaces.size} spaces" )

spaces.each do |space|
  #story name, space name
  story_name = space.getBuildingStory
  base_name = "#{story_name} - #{space_name}"
end #end of spaces.each do

Namely, OS does not like the " story_name = space.getBuildingStory" line. I have tried a few different iterations to get the story name based on the assigned space, but am coming up short. Any ideas?

This leads to the second part of my question. I have read/reviewed the 'Writing Measures' Guide and looked at the OpenStudio SDK, specifically the 'model' part of this documentation. It appears that this is all written with respect to C++/C# [guessing here?]. So, what is a good/best/better path to try to learn how to create Ruby scripts, but using this documentation reference? Is there some 'Rosetta Stone' that will help us novice mortals learn to use these scripts or the syntax? Reviewing Measures from the BCL is a path, and I have found it fairly straightforward to 'read' these files and follow what I believe is happening, but reading others scripts and drafting scripts are two different levels of competency. Thanks in advance for any help anyone can provide to either/both questions above.

OS Measure - Building Story

All; Thanks in advance for your assistance. I am a novice when it comes writing both with Ruby and OS Measures, but I am running head-long into it. So, this is really a two part question. First, I am working/playing with writing a measure to rename spaces based on the Building Story, but am having issues. The segment of code that is giving me fits is this: #get model objects spaces=model.getSpaces story=model.getBuidlingStorys

#reporting initial condition of model
runner.registerInitialCondition("The building has #{spaces.size} spaces" )

spaces.each do |space|
  #story name, space name
  story_name = space.getBuildingStory
  base_name = "#{story_name} - #{space_name}"
end #end of spaces.each do

Namely, OS does not like the " story_name = space.getBuildingStory" line. I have tried a few different iterations to get the story name based on the assigned space, but am coming up short. Any ideas?

This leads to the second part of my question. I have read/reviewed the 'Writing Measures' Guide and looked at the OpenStudio SDK, specifically the 'model' part of this documentation. It appears that this is all written with respect to C++/C# [guessing here?]. So, what is a good/best/better path to try to learn how to create Ruby scripts, but using this documentation reference? Is there some 'Rosetta Stone' that will help us novice mortals learn to use these scripts or the syntax? Reviewing Measures from the BCL is a path, and I have found it fairly straightforward to 'read' these files and follow what I believe is happening, but reading others scripts and drafting scripts are two different levels of competency. Thanks in advance for any help anyone can provide to either/both questions above.