Closed jmarrec closed 2 weeks ago
here is my test measure
# define the arguments that the user will input
def arguments(model)
args = OpenStudio::Measure::OSArgumentVector.new
isRead = false
extension = "CSV (*.csv);;Excel (*.xls *.xlsx);;All Files (*)"
required = true
modelDependent = false
output_path = OpenStudio::Measure::OSArgument.makePathArgument('output_path', isRead, extension, required, modelDependent)
output_path.setDisplayName('Output Path on Disk')
args << output_path
return args
end
# define what happens when the measure is run
def run(model, runner, user_arguments)
super(model, runner, user_arguments) # Do **NOT** remove this line
# use the built-in error checking
if !runner.validateUserArguments(arguments(model), user_arguments)
return false
end
# assign the user inputs to variables
output_path = runner.getPathArgumentValue('output_path', user_arguments)
puts "output_path=#{output_path}"
File.write(output_path.to_s, "hello")
# report final condition of model
runner.registerFinalCondition("The output path is #{output_path}")
return true
end
@macumber ping
This is cool @jmarrec, I added some comments, maybe it is worth adding some new attributes if you are already updating the SDK?
@macumber until #5273 is addressed, I'd say we just merge this. Does that work for you?
This looks good to me @jmarrec, I'm fine if you want to merge this now before https://github.com/NREL/OpenStudio/issues/5273 is complete
The OS SDK / BCL-gem implementation of the path arguments is incomplete and confusing, and they don't handle the makePathArgument arguments:
isRead
. what does that even mean? Is this assuming that this is for reading meaning it must be 1) a file (not a directory) and 2) it must exist?)extension