Eppy API

functions to edit the E+ model

class eppy.modeleditor.IDF(idfname=None)[source]

The IDF class holds all the information about an EnergyPlus IDF.

iddname
: str
Name of the IDD currently being used by eppy. As a class attribute, this is set for all IDFs which are currently being processed and cannot be changed for an individual IDF.
iddinfo
: list
Comments and metadata about fields in the IDD.
block
: list
Field names in the IDD.
idfname
: str
Path to the IDF file.
idfobjects
: list
List of EpBunch objects in the IDF.
model
: Eplusdata object
Data dictionary and list of objects for the entire model.
outputtype
: str
How to format the output of IDF.print or IDF.save, IDF.saveas or IDF.savecopy. The options are: ‘standard’, ‘nocomment’, ‘nocomment1’, ‘nocomment2’, and ‘compressed’.
copyidfobject(idfobject)[source]

Add an IDF object to the IDF.

idfobject
: EpBunch object
The IDF object to remove. This usually comes from another idf file, or it can be used to copy within this idf file.
getextensibleindex(key, name)[source]

Get the index of the first extensible item.

Only for internal use. # TODO : hide this

key
: str
The type of IDF object. This must be in ALL_CAPS.
name
: str
The name of the object to fetch.

int

getiddgroupdict()[source]

Return a idd group dictionary sample: {‘Plant-Condenser Loops’: [‘PlantLoop’, ‘CondenserLoop’],

‘Compliance Objects’: [‘Compliance:Building’], ‘Controllers’: [‘Controller:WaterCoil’,

‘Controller:OutdoorAir’, ‘Controller:MechanicalVentilation’, ‘AirLoopHVAC:ControllerList’],

...}

dict

classmethod getiddname()[source]

Get the name of the current IDD used by eppy.

str

getobject(key, name)[source]

Fetch an IDF object given key and name.

key
: str
The type of IDF object. This must be in ALL_CAPS.
name
: str
The name of the object to fetch.

EpBunch object.

idfstr()[source]

String representation of the IDF.

str

initnew(fname)[source]

Use the current IDD and create a new empty IDF. If the IDD has not yet been initialised then this is done first.

fname
: str, optional
Path to an IDF. This does not need to be set at this point.
initread(idfname)[source]

Use the current IDD and read an IDF from file. If the IDD has not yet been initialised then this is done first.

idf_name
: str
Path to an IDF file.
initreadtxt(idftxt)[source]

Use the current IDD and read an IDF from text data. If the IDD has not yet been initialised then this is done first.

idftxt
: str
Text representing an IDF file.
new(fname=None)[source]

Create a blank new idf file. Filename is optional.

fname
: str, optional
Path to an IDF. This does not need to be set at this point.
newidfobject(key, aname='', **kwargs)[source]

Add a new idfobject to the model. If you don’t specify a value for a field, the default value will be set.

For example

newidfobject("CONSTRUCTION")
newidfobject("CONSTRUCTION",
    Name='Interior Ceiling_class',
    Outside_Layer='LW Concrete',
    Layer_2='soundmat')
key
: str
The type of IDF object. This must be in ALL_CAPS.
aname
: str, deprecated
This parameter is not used. It is left there for backward compatibility.
**kwargs
Keyword arguments in the format field=value used to set the value of fields in the IDF object when it is created.

EpBunch object

popidfobject(key, index)[source]

Pop an IDF object from the IDF.

key
: str
The type of IDF object. This must be in ALL_CAPS.
index
: int
The index of the object to pop.

EpBunch object.

printidf()[source]

Print the IDF.

read()[source]

Read the IDF file and the IDD file. If the IDD file had already been read, it will not be read again.

Read populates the following data structures:

  • idfobjects : list
  • model : list
  • idd_info : list
  • idd_index : dict
removeextensibles(key, name)[source]

Remove extensible items in the object of key and name.

Only for internal use. # TODO : hide this

key
: str
The type of IDF object. This must be in ALL_CAPS.
name
: str
The name of the object to fetch.

EpBunch object

removeidfobject(idfobject)[source]

Remove an IDF object from the IDF.

idfobject
: EpBunch object
The IDF object to remove.
save(filename=None, lineendings='default', encoding='latin-1')[source]

Save the IDF as a text file with the optional filename passed, or with the current idfname of the IDF.

filename
: str, optional
Filepath to save the file. If None then use the IDF.idfname parameter. Also accepts a file handle.
lineendings
: str, optional
Line endings to use in the saved file. Options are ‘default’, ‘windows’ and ‘unix’ the default is ‘default’ which uses the line endings for the current system.
encoding
: str, optional
Encoding to use for the saved file. The default is ‘latin-1’ which is compatible with the EnergyPlus IDFEditor.
saveas(filename, lineendings='default', encoding='latin-1')[source]

Save the IDF as a text file with the filename passed.

filename
: str
Filepath to to set the idfname attribute to and save the file as.
lineendings
: str, optional
Line endings to use in the saved file. Options are ‘default’, ‘windows’ and ‘unix’ the default is ‘default’ which uses the line endings for the current system.
encoding
: str, optional
Encoding to use for the saved file. The default is ‘latin-1’ which is compatible with the EnergyPlus IDFEditor.
savecopy(filename, lineendings='default', encoding='latin-1')[source]

Save a copy of the file with the filename passed.

filename
: str
Filepath to save the file.
lineendings
: str, optional
Line endings to use in the saved file. Options are ‘default’, ‘windows’ and ‘unix’ the default is ‘default’ which uses the line endings for the current system.
encoding
: str, optional
Encoding to use for the saved file. The default is ‘latin-1’ which is compatible with the EnergyPlus IDFEditor.
classmethod setidd(iddinfo, iddindex, block)[source]

Set the IDD to be used by eppy.

iddinfo
: list
Comments and metadata about fields in the IDD.
block
: list
Field names in the IDD.
classmethod setiddname(iddname, testing=False)[source]

Set the path to the EnergyPlus IDD for the version of EnergyPlus which is to be used by eppy.

iddname
: str
Path to the IDD file.
testing
: bool
Flag to use if running tests since we may want to ignore the IDDAlreadySetError.

IDDAlreadySetError

Sub class Bunch to represent an IDF object.