I am using the Inject IDF Ojbects (correct spelling) Energyplus measure from the BCL and it doesn't add any objects.
The starting osm file is a freshly created osm, so blank except for whatever Openstudio puts in a new file.
My input parameter for the measure is "C:\Users\Mitchal Dichter\Desktop\find_me.idf" without the quotes.
The relevant code is
# report initial condtion
runner.registerInitialCondition("The initial IDF file had #{workspace.objects.size} objects.")
# load the idf file
if source_idf_path == ""
runner.registerError("No Source IDF File Path was Entered.")
return false
elsif not File.exists?(source_idf_path)
runner.registerError("File #{source_idf_path} does not exist.")
return false
elsif OpenStudio::IdfFile::load(OpenStudio::Path.new(source_idf_path)).empty?
runner.registerError("Cannot load #{source_idf_path}")
return false
else
# use OpenStudio::IdfFile instead of OpenStudio::Workspace so links to objects not in IDF will be maintained
source_idf = OpenStudio::IdfFile::load(OpenStudio::Path.new(source_idf_path)).get
end
# add everything from the file
workspace.addObjects(source_idf.objects)
# report final condition
runner.registerFinalCondition("The final IDF file had #{workspace.objects.size} objects.")
and the output from Run Simulation in Energyplus is
Applying InjectIDFOjbects
Result: Success
Initial Condition: The initial IDF file had 24 objects.
Final Condition: The final IDF file had 24 objects.
Starting Simulation.
The two important lines are
source_idf = OpenStudio::IdfFile::load(OpenStudio::Path.new(source_idf_path)).get
workspace.addObjects(source_idf.objects)
The code gets past the error checking, so the idf file exists, is not empty, and loaded successfully, but workspace.addObjects(source_idf.objects) doesn't add any objects.
Is this the most up to date syntax? I noticed a couple different ways to get an idf file and for addObjects in UnmetHours.
I also noticed this line in the file:
class InjectIDFOjbects < OpenStudio::Ruleset::WorkspaceUserScript
I there anything special I should do to use a WorkspaceUserScript?