Class: BTAP::Measures::OSMeasures::ArchetypeScan
- Inherits:
-
BTAPModelUserScript
- Object
- OpenStudio::Ruleset::ModelUserScript
- BTAPModelUserScript
- BTAP::Measures::OSMeasures::ArchetypeScan
- Defined in:
- lib/openstudio-standards/btap/measures.rb
Instance Attribute Summary
Attributes inherited from BTAPModelUserScript
#argument_array, #argument_array_of_arrays, #file
Instance Method Summary collapse
- #arguments(model) ⇒ Object
- #name ⇒ Object
- #run(model, runner, user_arguments) ⇒ Object
-
#set_user_arguments_and_apply(model, argument_values, runner) ⇒ Object
For manually running script via an IDE or a command line script.
Methods inherited from BTAPModelUserScript
#argument_getter, #argument_setter, #generate_ruby_macro
Instance Method Details
#arguments(model) ⇒ Object
376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/openstudio-standards/btap/measures.rb', line 376 def arguments(model) #get all osm files in resource folder. osmfiles = OpenStudio::StringVector.new BTAP::FileIO::get_find_files_from_folder_by_extension(File.dirname(__FILE__), ".osm").each {|filename| osmfiles << File.basename(file_name, ",osm")} #list of arguments as they will appear in the interface. They are available in the run command as @variable_name. @argument_array_of_arrays = [ [ "variable_name", "type", "required", "model_dependant", "display_name", "default_value", "min_value", "max_value", "string_choice_array", "os_object_type" ], [ "archetype_name", "STRINGCHOICE", true, false, "archetype_name", osmfiles[0].to_s , nil, nil, osmfiles, nil ], ] args = super(model,@argument_array_of_arrays) return args end |
#name ⇒ Object
372 373 374 |
# File 'lib/openstudio-standards/btap/measures.rb', line 372 def name "BTAPTempModelMeasure" end |
#run(model, runner, user_arguments) ⇒ Object
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/openstudio-standards/btap/measures.rb', line 391 def run(model, runner, user_arguments) #run the super parent_method_is_true = super(model, runner, user_arguments) ############### #Set Archetype name in runner. runner.registerValue('archetype_name',@archetype_name) #Set path to OSM files. alternative_model_path = OpenStudio::Path.new("#{File.dirname(__FILE__)}/#{@archetype_name}.osm") #load model and test. translator = OpenStudio::OSVersion::VersionTranslator.new oModel = translator.loadModel(alternative_model_path) if oModel.empty? runner.registerError("Could not load alternative model from '" + alternative_model_path.to_s + "'.") return false end new_model = oModel.get # pull original weather file object over weather_file = new_model.getOptionalWeatherFile if not weather_file.empty? weather_file.get.remove runner.registerInfo("Removed alternate model's weather file object.") end original_weather_file = model.getOptionalWeatherFile if not original_weather_file.empty? original_weather_file.get.clone(new_model) end # pull original design days over new_model.getDesignDays.sort.each { |designDay| designDay.remove } model.getDesignDays.sort.each { |designDay| designDay.clone(new_model) } #swap underlying data in model with underlying data in newModel model.swap(new_model) runner.registerFinalCondition("Model replaced with alternative #{alternative_model_path}.") return true ? parent_method_is_true : false end |
#set_user_arguments_and_apply(model, argument_values, runner) ⇒ Object
For manually running script via an IDE or a command line script. Using the template above as an example.….
argument_values = [
["archetype_name", "FullServiceRestaurant" ]
]
439 440 441 |
# File 'lib/openstudio-standards/btap/measures.rb', line 439 def set_user_arguments_and_apply(model,argument_values,runner) self.run(model, runner, super(model,argument_values,runner) ) end |