Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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)

# load OSM file
osm_model = OpenStudio::Model::Model::replace_model(osm_file).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)

# load OSM file
osm_model 
translator = OpenStudio::Model::Model::replace_model(osm_file).get
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