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

argument in reporting measure

asked 2016-02-09 13:17:05 -0500

ngkhanh's avatar

updated 2017-01-31 17:22:38 -0500

I get fault with this code :

def arguments()      
   args =
   all_scheds = model.getSchedules
    sched_name_vec =
    all_scheds.each do |sched|
    sched_name_vec <<
    sched_name = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('Occupancy Schedule',sched_name_vec,false)
    sched_name.setDisplayName("Choose Occupancy Schedule")
    args << sched_name
    return args
  end #end the arguments method

  # return a vector of IdfObject's to request EnergyPlus objects needed by the run method
  def energyPlusOutputRequests(runner, user_arguments)
    super(runner, user_arguments)

    result =

    # use the built-in error checking
    if !runner.validateUserArguments(arguments(), user_arguments)
      return result
    request = OpenStudio::IdfObject.load("Output:Table:SummaryReports,AllSummaryAndSizingPeriod;").get
    result << request
    request = OpenStudio::IdfObject.load("Output:Table:TimeBins,*,Zone Air Temperature,14,2,8,,Temperature;").get
    result << request
    return result

It gets undefined variable or method for model while i want to get all schedule as choices for my argument in a reporting measure. How to configure argument in reporting measure ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-09 14:02:44 -0500

updated 2017-01-11 00:55:17 -0500

It just doesn't know what your model is.

Check out the Mesure Writing Guide, there's a "reporting measure" section that should prove most interesting.

If your case, you currently cannot access it in the arguments method.

If you wanted to do something in the run method, you could do this:

model = runner.lastOpenStudioModel
if model.empty?
  runner.registerError("Cannot find last model.")
  return false
model = model.get

# then "model" is actually initialized and you can get your schedules

You can see the function signatures for these in ReportingMeasure.hpp.

Note: this used to be called ReportingUserScript before OS 2.0.0.

edit flag offensive delete link more



Julian is correct and his code would work in the run method (the runner is passed to run) but would not currently work in the arguments method (the runner is not passed to the arguments method).

macumber's avatar macumber  ( 2016-02-09 14:06:28 -0500 )edit

Can you just pass it to the arguments method? Or do you mean "in the current version of OS"?

Julien Marrec's avatar Julien Marrec  ( 2016-02-09 14:10:25 -0500 )edit

The function signatures for the reporting measures can be found here. That shows the arguments that will be passed in to the methods when OpenStudio runs your measure.

macumber's avatar macumber  ( 2016-02-09 14:13:44 -0500 )edit

@macumber : so am i able to read model/workspace input Argument method in Reporting measure ? If answer is "yes", i would like to see an example of code.

ngkhanh's avatar ngkhanh  ( 2016-02-09 14:50:25 -0500 )edit

The answer is currently no. If you want to report values for a particular node or something like that you can pass in a string that you can use to find the right object during the run method.

macumber's avatar macumber  ( 2016-02-10 10:26:38 -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

Question Tools

1 follower


Asked: 2016-02-09 13:17:05 -0500

Seen: 216 times

Last updated: Jan 31 '17