Class: FromHoneybeeModelToGbxml
- Inherits:
-
OpenStudio::Measure::ModelMeasure
- Object
- OpenStudio::Measure::ModelMeasure
- FromHoneybeeModelToGbxml
- Defined in:
- lib/measures/from_honeybee_model_to_gbxml/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(model) ⇒ Object
define the arguments that the user will input.
-
#description ⇒ Object
human readable description.
-
#modeler_description ⇒ Object
human readable description of modeling approach.
-
#name ⇒ Object
human readable name.
-
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(model) ⇒ Object
define the arguments that the user will input
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/measures/from_honeybee_model_to_gbxml/measure.rb', line 56 def arguments(model) args = OpenStudio::Measure::OSArgumentVector.new # Make an argument for the honyebee model json model_json = OpenStudio::Measure::OSArgument.makeStringArgument('model_json', true) model_json.setDisplayName('Path to the Honeybee Model JSON file') args << model_json # Make an argument for the output file path output_file_path = OpenStudio::Measure::OSArgument.makeStringArgument('output_file_path', false) output_file_path.setDisplayName('Output file path') output_file_path.setDescription('If set, the output gbXML file will be exported to this path. Othervise The file will be exported to the same path as the input model.') output_file_path.setDefaultValue('') args << output_file_path return args end |
#description ⇒ Object
human readable description
46 47 48 |
# File 'lib/measures/from_honeybee_model_to_gbxml/measure.rb', line 46 def description return 'Translate a JSON file of a Honeybee Model into a gbXML Model.' end |
#modeler_description ⇒ Object
human readable description of modeling approach
51 52 53 |
# File 'lib/measures/from_honeybee_model_to_gbxml/measure.rb', line 51 def modeler_description return 'Translate a JSON file of a Honeybee Model into a gbXML Model.' end |
#name ⇒ Object
human readable name
41 42 43 |
# File 'lib/measures/from_honeybee_model_to_gbxml/measure.rb', line 41 def name return 'From Honeybee Model to gbXML' end |
#run(model, runner, user_arguments) ⇒ Object
define what happens when the measure is run
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/measures/from_honeybee_model_to_gbxml/measure.rb', line 75 def run(model, runner, user_arguments) super(model, runner, user_arguments) STDOUT.flush if !runner.validateUserArguments(arguments(model), user_arguments) return false end # convert the Honeybee model into an OpenStudio Model model_json = runner.getStringArgumentValue('model_json', user_arguments) if !File.exist?(model_json) runner.registerError("Cannot find file '#{model_json}'") return false end honeybee_model = Honeybee::Model.read_from_disk(model_json) $simple_window_cons = true $orphan_groups = false STDOUT.flush os_model = honeybee_model.to_openstudio_model(model) STDOUT.flush # convert the OpenStudio model into a gbXML Model output_file_path = runner.getStringArgumentValue('output_file_path', user_arguments) if output_file_path && !output_file_path.empty? unless File.exist?(output_file_path) output_folder = File.split(output_file_path)[0] FileUtils.mkdir_p(output_folder) end else model_path, model_name = File.split(model_json) gbxml_model_name = model_name.split('.')[0] + '.gbxml' output_file_path = File.join(model_path, gbxml_model_name) end translator = OpenStudio::GbXML::GbXMLForwardTranslator.new translator.modelToGbXML(os_model, output_file_path) return true end |