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

Using Eppy to export IDF objects

asked 2016-08-12 07:38:22 -0500

andrea.botti gravatar image

updated 2016-08-13 03:45:01 -0500

I am trying to pre-process an IDF file (exported from DesignBuilder or OpenStudio) to use it with jEPlus. Thanks to the help I received on this forum I have managed to replace selected parameters with jEPlus variables, which is great.

My next step is to 'assemble' an IDF file, by:

  • extracting objects from an IDF files
  • saving them as a separate IDF files (or INP input file) to be subsequently called by EP-macro, within jEPlus.

For instance, I would like to use the geometry built with DesignBuilder - by extracting idf.idfobjects['BUILDINGSURFACE:DETAILED'] - and copy this in a new file where all other objects are called through EP-macro (i.e. schedules, materials, output variables etc).

Also, could these objets be exported in a different format, (i.e. CSV) in order to visualise them? I have tried to use the commands .saveas() and .to_csv in eppy but neither of those seem to work.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-12 13:16:30 -0500

updated 2016-08-15 12:30:32 -0500

For the first question, you can create a second IDF and add the extracted objects to it.

# get the geometry objects
surfaces = idf.idfobjects['BUILDINGSURFACE:DETAILED']
windows = idf.idfobjects['WINDOW']

# make a new empty IDF
idf2 = IDF()

# copy the geometry objects into the new IDF
for s, w in zip(surfaces, windows):

# save the geometry as an IMF for use by EPMacro

For the second question, IDF.saveas() is just to change the filename. It doesn't really make sense to save it as a CSV since each object has different fields. I suppose you could do something like:

headers = surfaces[0].objls  # get the column headers as a list
rows = [s.obj for s in surfaces] # get the values as a list of lists
with open('out.csv', 'w') as f_out:
    f_out.write(','.join(str(i) for i in headers) + '\n')
    for row in rows:
        f_out.write(','.join(str(i) for i in row) + '\n')

Alternatively you could open up the IDF in the OpenStudio SketchUp plugin to get a visualisation of the surfaces and windows in the model.

In response to your comment, you need to tell eppy which output variable you want to remove from the IDF. The simple case first:

# to remove them all
for variable in idf.idfobjects['OUTPUT:VARIABLE']:

Removing a specific variable can be a bit tricky though. Since they don't have a Name field we can't select them using idf.getobject('OUTPUT:VARIABLE', name). They do have a Key_Value field, though this is often *, and a Variable_Name field. We can use those in a list comprehension to filter out the variable or variables to remove.

# to remove all variables of a given Variable_Name
name = "Electric Equipment Electric Energy"
variables = [v for v in idf.idfobjects['OUTPUT:VARIABLE'] if v.Variable_Name == name]
for variable in variables :

# to remove variables with a given Variable_Name with a specific Key_Value
key_value = "PrimaryHeater"
name = "Boiler Gas Energy"
variables = [v for v in idf.idfobjects['OUTPUT:VARIABLE'] 
                      if v.Variable_Name == name
                      and v.Key_Value == key_value]
for variable in variables :
edit flag offensive delete link more



Jamie, thanks very much for your answer. Similarly, is there a way to drop selected IDF objects in Eppy? I have tried idf.removeidfobject('OUTPUT:VARIABLE') but that does not seem to work

andrea.botti gravatar imageandrea.botti ( 2016-08-15 10:33:58 -0500 )edit

I've edited the answer to cover your situation. OUTPUT:VARIABLEs are a tricky example but there's a few ways to do it.

Jamie Bull gravatar imageJamie Bull ( 2016-08-15 12:31:46 -0500 )edit

I have tried to use the code you suggested to remove all output variables:

for variable in idf.idfobjects['OUTPUT:VARIABLE']:

but nearly half of the variables remain.

Some might argue that it does not matter how many variables are there, as what matters is actually what one instructs jeplus to collect through the rvi/rvx. While that is true, I find that sometimes I need to go through the .eso files (for any of the iterations) to explore the results, and I find having too many irrelevant output variables very confusing.

andrea.botti gravatar imageandrea.botti ( 2016-08-17 12:38:46 -0500 )edit

Would it be possible for me to remove variables whose Variable_Name or Key_Value contain a specific string, rather than perfect name matching? (Don't hate me! :) )

andrea.botti gravatar imageandrea.botti ( 2016-08-17 12:41:23 -0500 )edit

Interesting that not everything gets removed in the simple case. Not sure why that is. In general, all this stuff about output variables should really be in another question though. It's nothing to do with the original question here so no-one in future is likely to be able to find it.

Jamie Bull gravatar imageJamie Bull ( 2016-08-17 14:43:34 -0500 )edit

Your Answer

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

Add Answer


Question Tools

1 follower


Asked: 2016-08-12 07:38:22 -0500

Seen: 236 times

Last updated: Aug 15 '16