Authors: Santosh Philip, Leora Tanjuatco
Eppy is a scripting language for E+ idf files, and E+ output files. Eppy is written in the programming language Python. As a result it takes full advantage of the rich data structure and idioms that are avaliable in python. You can programmatically navigate, search, and modify E+ idf files useing eppy. The power of using a scripting language allows you to do the following:
So what does this matter?
Here are some of the things you can do with eppy:
Here is a short IDF file that I’ll be using as an example to start us off:
To use eppy to look at this model, we have to run a little code first:
In [1]:
import modeleditor
from modeleditor import IDF
iddfile = "../iddfiles/Energy+V7_2_0.idd"
IDF.setiddname(iddfile)
fname1 = "../idffiles/V_7_2/smallfile.idf"
idf1 = IDF(fname1)
Now that the behind-the-scenes work is done, we can print the model using this command:
For this example, we have named the file "idf1". So the command looks like this:
In [2]:
idf1.printidf()
Looks like the same file as before, except that all the comments have been removed. Well ... this version of eppy is not smart enough to deal with comments. It just removes all of them :-(
As you can see, this file has four objects:
So, let us look take a closer look at the BUILDING object:
In [3]:
print idf1.idfobjects['BUILDING'] # put the name of the object you'd like to look at in brackets
We can also zoom in on the object and look just at its individual parts.
For example, let us look at the name of the building:
In [4]:
building = idf1.idfobjects['BUILDING'][0] # more behind-the-scenes work
# we'll explain the [0] later
In [5]:
print building.Name
Now that we've isolated the building name, we can change it.
In [6]:
building.Name = "Empire State Building"
In [7]:
print building.Name
Did this actually change the name in the model ? Let us print the entire model and see.
In [8]:
idf1.printidf()
Yes! It did. So we know we can change any field in any object.
In [ ]: