Inject IDF Objects measure not adding objects
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 Openstudio 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?
Seems like for some reason OpenStudio isn't finding objects in the idf. If you add a line with runner.registerInfo(source_idf.objects.size) it will probably show 0. Is the idf file you are injecting the same version of EnergyPlus used by the version of OpenStudio you are using? Are there just a few objects in the IDF. If so maybe you can update the question with the text from the idf file. Otherwise posting th file on file sharing site may be necessary.
@David Goldwasser The problem was the IDF version of the find_me.idf. I updated it and everything ran fine. Thanks! I never would've thought of that. I was thinking maybe the syntax had changed since the measure had been written.
@mldichter Could you please share the IDF file you used to inject objects? It has been a couple of weeks that I am trying to inject CHP unit into OpenStudio but I am not familiar with IDF writing so I am struggling a lot, maybe if I could see a template I could understand it better Thanks :)
@Raghda Derbel Can you add a link to a screenshot of what your setup is and where the error is occuring? I don't understand which part of the process you are stuck on.
@mldichter, I posted a question about it here with screenshots, but I still have no answer since. I would appreciate your help. Thanks :)