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

Revision history [back]

You can add each variable in the measure tab with multiple 'Add Ouput Variable' measures, but this can get kind of tedious. Instead, if you have all your favorite Output:Variable objects loaded in an .idf file called outputs.idf, you can write an OpenStudio measure with that file in the measure folder in a subdirectory call 'resources'. Now in your measure, you can load that idf into an OpenStudio workspace with

library = OpenStudio:Workspace:load("#{File.dirname(__FILE__)}/resources/outputs.idf").get

then translate this idf to osm using the Reverse Translator:

rt = OpenStudio::EnergyPlus::ReverseTranslator.new
library_model = rt.translateWorkspace(library)

Now all you have to do is get all the output variables from the library model, and add them to your model:

#get variables from library model
vars = library_model.getOutputVariables

#loop through each variable and add that variable to the model
vars.each do |var|
  variable_name = var.variableName
  newVariable = OpenStudio::Model::OutputVariable.new(variable_name,model)
end

You can add a measure argument to choose a reporting frequency, and add newVariable.setReportingFrequency(reporting_frequency) inside the loop above. Now you have one measure to add whatever number of output variables that you'd like, with no need to fuss in your model's idf.

You can add each variable in the measure tab with multiple 'Add Ouput Variable' measures, but this can get kind of tedious. Instead, if you have all your favorite Output:Variable objects loaded in an .idf file called outputs.idf, you can write an OpenStudio measure with that file in the measure folder in a subdirectory call 'resources'. Now in your measure, you can load that idf into an OpenStudio workspace with

library = OpenStudio:Workspace:load("#{File.dirname(__FILE__)}/resources/outputs.idf").get

then translate this idf to osm using the Reverse Translator:Translator (which will translate Output:Variable objects):

rt = OpenStudio::EnergyPlus::ReverseTranslator.new
library_model = rt.translateWorkspace(library)

Now all you have to do is get all the output variables from the library model, and add them to your model:

#get variables from library model
vars = library_model.getOutputVariables

#loop through each variable and add that variable to the model
vars.each do |var|
  variable_name = var.variableName
  newVariable = OpenStudio::Model::OutputVariable.new(variable_name,model)
end

You can add a measure argument to choose a reporting frequency, and add newVariable.setReportingFrequency(reporting_frequency) inside the loop above. Now you have one measure to add whatever number of output variables that you'd like, with no need to fuss in your model's idf.

You can add each variable in the measure tab with multiple 'Add Ouput Variable' measures, but this can get kind of tedious. Instead, if you have all your favorite Output:Variable objects loaded in an .idf file called outputs.idf, you can write an OpenStudio measure with that file in the measure folder in a subdirectory call 'resources'. 'resources' subdirectory. Now in your measure, you can load that idf into an OpenStudio workspace with

library = OpenStudio:Workspace:load("#{File.dirname(__FILE__)}/resources/outputs.idf").get

then translate this idf to osm using the Reverse Translator (which will translate Output:Variable objects):

rt = OpenStudio::EnergyPlus::ReverseTranslator.new
library_model = rt.translateWorkspace(library)

Now all you have to do is get all the output variables from the library model, and add them to your model:

#get variables from library model
vars = library_model.getOutputVariables

#loop through each variable and add that variable to the model
vars.each do |var|
  variable_name = var.variableName
  newVariable = OpenStudio::Model::OutputVariable.new(variable_name,model)
end

You can add a measure argument to choose a reporting frequency, and add newVariable.setReportingFrequency(reporting_frequency) inside the loop above. Now you have one measure to add whatever number of output variables that you'd like, with no need to fuss in your model's idf.