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

Revision history [back]

I'll let @macumber give longer answer but what I think you want is something like this.

idf = workspace.toIdfFile()

I use that method on the Inject OSM Geometry into an External IDF measure. This measure takes the IDF generated from the OSM and merges it with a user specified IDF file. The geometry comes form the OSM generated IDF, and everything else comes from the user specified IDF. I hit the same issue you did.

Here is some of the code from the linked measure.

#get model from path and error if empty
source_idf = OpenStudio::Workspace::load(OpenStudio::Path.new(source_idf_path))
if source_idf.empty?
  runner.registerError("Cannot load #{source_idf_path}")
  return false
end
source_idf = source_idf.get

#to preserve links I need to get an IdfFile from Workspace
source_idfFile = source_idf.toIdfFile()

#get source_idf surfaces
source_idf_BuildingSurfaces = source_idfFile.getObjectsByType("BuildingSurface_Detailed".to_IddObjectType)

#reporting initial condition of model
runner.registerInitialCondition("The source IDF has #{source_idf_BuildingSurfaces.size} BuildingSurface_Detail objects.")

I'll let @macumber give longer answer but what I think you want is something like this.

idf = workspace.toIdfFile()

I use that method on the Inject OSM Geometry into an External IDF measure. This measure takes the IDF generated from the OSM and merges it with a user specified IDF file. The geometry comes form from the OSM generated IDF, and everything else comes from the user specified IDF. I hit the same issue you did.

Here is some of the code from the linked measure.

#get model from path and error if empty
source_idf = OpenStudio::Workspace::load(OpenStudio::Path.new(source_idf_path))
if source_idf.empty?
  runner.registerError("Cannot load #{source_idf_path}")
  return false
end
source_idf = source_idf.get

#to preserve links I need to get an IdfFile from Workspace
source_idfFile = source_idf.toIdfFile()

#get source_idf surfaces
source_idf_BuildingSurfaces = source_idfFile.getObjectsByType("BuildingSurface_Detailed".to_IddObjectType)

#reporting initial condition of model
runner.registerInitialCondition("The source IDF has #{source_idf_BuildingSurfaces.size} BuildingSurface_Detail objects.")