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

Inject IDF Objects measure not adding objects

asked 2018-06-15 15:56:40 -0500

mldichter's avatar

updated 2018-06-16 08:55:03 -0500

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?

edit retag flag offensive close merge delete

Comments

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's avatar David Goldwasser  ( 2018-06-15 22:00:50 -0500 )edit

@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's avatar mldichter  ( 2018-06-16 11:14:01 -0500 )edit

@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's avatar Raghda Derbel  ( 2018-09-05 08:56:27 -0500 )edit

@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's avatar mldichter  ( 2018-09-05 13:04:51 -0500 )edit

@mldichter, I posted a question about it here with screenshots, but I still have no answer since. I would appreciate your help. Thanks :)

Raghda Derbel's avatar Raghda Derbel  ( 2018-09-06 10:56:21 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-06-16 11:16:03 -0500

mldichter's avatar

From @David Goldwasser's comment, the problem was the version of the IDF file find_me.idf was 8.8 instead of 8.9. Once I updated the find_me.idf to 8.9 the measure worked fine.

edit flag offensive delete link more

Comments

Glad that worked, next time I update the measure I can add in a warning log if 0 objects are in the idf.

David Goldwasser's avatar David Goldwasser  ( 2018-06-16 11:52:07 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2018-06-15 15:56:40 -0500

Seen: 210 times

Last updated: Jun 16 '18