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

Revision history [back]

The typical way to load a model when using the API is to call the VersionTranslator object, this will upgrade any model created in an earlier version to the specific version you're using.

I've personally created a helper function that I load whenever I launch a new Pry (ruby) session. Syntax below is in ruby, but easily adapted to your specific language bindings.

# Helper to load a model in one line
def osload(path)
  translator = OpenStudio::OSVersion::VersionTranslator.new
  ospath = OpenStudio::Path.new(path)
  model = translator.loadModel(ospath)
  if model.empty?
      raise "Path '#{path}' is not a valid path to an OpenStudio Model"
  else
      model = model.get
  end  
  return model
end

This allows me to do model = osload('mymodel.osm'), which I find to be a big time saver considering how many times I do this in a given modeling day.

See the Measure Writing guide, Model and Workspace Creation, Loading, the "Load Existing Model" especially.