First time here? Check out the Help page!
1 | initial version |
If you're certain the osm version is the same as the API you are using, the following should work:
model = OpenStudio::Model::Model.load(osm_file).get
2 | No.2 Revision |
If you're certain the osm version is the same as the API you are using, the following should work:
model = OpenStudio::Model::Model.load(osm_file).get
The 'safer' way, as @mdahlhausen suggested, is to load thru the version translator, like:
model_path = OpenStudio::Path.new(osm_path)
version_translator = OpenStudio::OSVersion::VersionTranslator.new
if OpenStudio::exists(model_path)
model = version_translator.loadModel(model_path)
if model.empty?
puts "Version translation failed for #{model_path}"
else
model = model.get
end
else
puts "The model couldn't be found at #{model_path}"
end
3 | No.3 Revision |
If you're certain the osm version is the same as the API you are using, the following should work:
model = OpenStudio::Model::Model.load(osm_file).get
The 'safer' way, as @mdahlhausen suggested, is to load thru the version translator, as well as checking that everything exists ('is_initialized', or not 'empty') like:
model_path = OpenStudio::Path.new(osm_path)
version_translator = OpenStudio::OSVersion::VersionTranslator.new
if OpenStudio::exists(model_path)
model = version_translator.loadModel(model_path)
if model.empty?
puts "Version translation failed for #{model_path}"
else
model = model.get
end
else
puts "The model couldn't be found at #{model_path}"
end
4 | No.4 Revision |
If you're certain the osm version is the same as the API you are using, the following should work:
model = OpenStudio::Model::Model.load(osm_file).get
The 'safer' way, as @mdahlhausen suggested, is to load thru the version translator, as well as checking that everything exists ('is_initialized', or not 'empty') 'empty'). As a handy function, it would look like:
def load_model(osm_path)
model_path = OpenStudio::Path.new(osm_path)
version_translator = OpenStudio::OSVersion::VersionTranslator.new
if OpenStudio::exists(model_path)
model = version_translator.loadModel(model_path)
if model.empty?
puts "Version translation failed for #{model_path}"
else
model = model.get
return model
end
else
puts "The model couldn't be found at #{model_path}"
end
end