src/utilities/bcl/templates/ModelMeasure/measure.rb
def run(model, runner, user_arguments)
    super(model, runner, user_arguments)

    # use the built-in error checking
    if !runner.validateUserArguments(arguments(model), user_arguments)
      return false
    end

    # assign the user inputs to variables
    space_name = runner.getStringArgumentValue('space_name', user_arguments)

    # check the space_name for reasonableness
    if space_name.empty?
      runner.registerError('Empty space name was entered.')
      return false
    end

    # report initial condition of model
    runner.registerInitialCondition("The building started with #{model.getSpaces.size} spaces.")

    # add a new space to the model
    new_space = OpenStudio::Model::Space.new(model)
    new_space.setName(space_name)

    # echo the new space's name back to the user
    runner.registerInfo("Space #{new_space.name} was added.")

    # report final condition of model
    runner.registerFinalCondition("The building finished with #{model.getSpaces.size} spaces.")

    return true
  end
# define what happens when the measure is run
define what happens when the measure is run
define what happens when the measure is run
def run(model, runner, user_arguments)
    super(model, runner, user_arguments)
    if !runner.validateUserArguments(arguments(model), user_arguments)
      return false
    end
    space_name = runner.getStringArgumentValue('space_name', user_arguments)
    if space_name.empty?
      runner.registerError('Empty space name was entered.')
      return false
    end
    runner.registerInitialCondition("The building started with #{model.getSpaces.size} spaces.")
    new_space = OpenStudio::Model::Space.new(model)
    new_space.setName(space_name)
    runner.registerInfo("Space #{new_space.name} was added.")
    runner.registerFinalCondition("The building finished with #{model.getSpaces.size} spaces.")
    return true
  end
def run ( model , runner , user_arguments ) super ( model , runner , user_arguments ) if ! runner . validateUserArguments ( arguments ( model ) , user_arguments ) return false end space_name = runner . getStringArgumentValue ( 'space_name' , user_arguments ) if space_name . empty? runner . registerError ( 'Empty space name was entered.' ) return false end runner . registerInitialCondition ( "The building started with #{model.getSpaces.size} spaces." ) new_space = OpenStudio :: Model :: Space . new ( model ) new_space . setName ( space_name ) runner . registerInfo ( "Space #{new_space.name} was added." ) runner . registerFinalCondition ( "The building finished with #{model.getSpaces.size} spaces." ) return true end
define what happens when the measure is run
define what happens when the measure is run
# use the built-in error checking # assign the user inputs to variables # check the space_name for reasonableness # report initial condition of model # add a new space to the model # echo the new space's name back to the user # report final condition of model
model
runner
user_arguments