I want to include an optional argument for a measure, that the user would leave blank if not needed. The problem is that when I'm trying to retrieve the value, if left blank it crashes.
Here's an example of what I want to do:
def arguments(model)
args = OpenStudio::Ruleset::OSArgumentVector.new
#Optional argument
fan_pressure_rise = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('fan_pressure_rise', false)
fan_pressure_rise.setDisplayName('Fan Pressure Rise (Pa)')
fan_pressure_rise.setDescription('Leave blank for default value')
args << fan_pressure_rise
return args
end # end the arguments method
def run(model, runner, user_arguments)
super(model, runner, user_arguments)
# use the built-in error checking
if not runner.validateUserArguments(arguments(model), user_arguments)
return false
end
fan_pressure_rise = runner.getDoubleArgumentValue('fan_pressure_rise', user_arguments)
return true
end # end the run method
I get the following error:
'getDoubleArgumentValue': No value found for argument 'fan_pressure_rise' (RuntimeError)
How can I deal with optional, potentially blank arguments in OpenStudio measures?