Revision history  [back]

Load OSM file in measure scripting

How do I get a measure to load a specific OSM from a resources directory. I am using the following code and it finds the model but doesn't load it in to be run.

  # assign the user inputs to variables
osm_file_name = runner.getStringArgumentValue("osm_file_name", user_arguments)
osm_directory = runner.getStringArgumentValue("osm_directory", user_arguments)

# get the path
osm_directory = File.expand_path(File.join(File.dirname(__FILE__), osm_directory))

#merge file name and path
osm_file = File.join(osm_directory, osm_file_name)


translator = OpenStudio::OSVersion::VersionTranslator.new
ospath = OpenStudio::Path.new(osm_directory)
model = translator.loadModel(ospath)
model = model.get

Load OSM file in measure scripting

How do I get a measure to load a specific OSM from a resources directory. I am using the following code and it finds the model but doesn't load it in to be run.

  # assign the user inputs to variables
osm_file_name = runner.getStringArgumentValue("osm_file_name", user_arguments)
osm_directory = runner.getStringArgumentValue("osm_directory", user_arguments)

# get the path
osm_directory = File.expand_path(File.join(File.dirname(__FILE__), osm_directory))

#merge file name and path
osm_file = File.join(osm_directory, osm_file_name)


translator = OpenStudio::OSVersion::VersionTranslator.new
ospath = OpenStudio::Path.new(osm_directory)
model = translator.loadModel(ospath)
model = model.get

Load OSM file in measure scripting

How do I get a measure to load a specific OSM from a resources directory. I am using the following code and it finds the model but doesn't load it in to be run.

 # assign the user inputs to variables
osm_file_name = runner.getStringArgumentValue("osm_file_name", user_arguments)
osm_directory = runner.getStringArgumentValue("osm_directory", user_arguments)

# get the path
osm_directory = File.expand_path(File.join(File.dirname(__FILE__), osm_directory))

#merge file name and path
osm_file = File.join(osm_directory, osm_file_name)


translator # load OSM file
osm_model = OpenStudio::OSVersion::VersionTranslator.new
ospath = OpenStudio::Path.new(osm_directory)
model = translator.loadModel(ospath)
model = model.get
OpenStudio::Model::Model::replace_model(osm_file).get