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

# Revision history [back]

### Using Eppy to replace recurring strings in an IDF file

Hello, I am trying to pre-process an IDF file (exported from DesignBuilder or OpenStudio) to use it with jEPlus.

As I am trying to 'assemble' a custom IDF file, using bits and pieces from different sources, I would like to manipulate an IDF, exported from DB, to combine it with objects that have customised names.

For surfaces, I managed to replace each surface name with a simpler name, the latter including the name of the zone, the type of surface and its azimuth.

The code:

s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm[:5]:
print '\n', name, azimuth
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)
print name


returns:

Block1:B1_GroundFloor_0_0_0 0.0
B1_GroundFloor_0.0

Block1:B1_Roof_1_0_0 0.0
B1_Roof_0.0

Block1:B1_Partition_2_0_0 90.0
B1_Partition_90.0

Block2:LR_Partition_4_0_10000 270.0
LR_Partition_270.0

Block1:B1_Wall_3_0_0 0.0
B1_Wall_0.0


which is what I wanted.

However, you all know that names are always cross referenced in a IDF file, thus what I am after is really a script capable of running a find and replace function throughout the IDF file.

Is there a way to run the string.replace(old_name, new_name) for an entire IDF file?

### Using Eppy to replace recurring strings in an IDF file

Hello, I am trying to pre-process an IDF file (exported from DesignBuilder or OpenStudio) to use it with jEPlus.

As I am trying to 'assemble' a custom IDF file, using bits and pieces from different sources, I would like to manipulate an IDF, exported from DB, to combine it with objects that have customised names.

For surfaces, I managed to replace each surface name with a simpler name, the latter including the name of the zone, the type of surface and its azimuth.

The code:

s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm[:5]:
print '\n', name, azimuth
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)
print name


returns:

Block1:B1_GroundFloor_0_0_0 0.0
B1_GroundFloor_0.0

Block1:B1_Roof_1_0_0 0.0
B1_Roof_0.0

Block1:B1_Partition_2_0_0 90.0
B1_Partition_90.0

Block2:LR_Partition_4_0_10000 270.0
LR_Partition_270.0

Block1:B1_Wall_3_0_0 0.0
B1_Wall_0.0


which is what I wanted.

However, you all know that names are always cross referenced in a IDF file, thus what I am after is really a script capable of running a find and replace function throughout the IDF file.

Is there a way to run the string.replace(old_name, new_name) for an entire IDF file?file? My aim is that every string 'Block*:' is replaced with '' (so effectively deleted).

Thanks, Andrea

### Using Eppy to replace recurring strings in an IDF file

Hello, I am trying to pre-process an IDF file (exported from DesignBuilder or OpenStudio) to use it with jEPlus.

As I am trying to 'assemble' a custom IDF file, using bits and pieces from different sources, I would like to manipulate an IDF, exported from DB, to combine it with objects that have customised names.

For surfaces, I managed to replace each surface name with a simpler name, the latter including the name of the zone, the type of surface and its azimuth.

The code:

s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm[:5]:
print '\n', name, azimuth
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)
print name


returns:

Block1:B1_GroundFloor_0_0_0 0.0
B1_GroundFloor_0.0

Block1:B1_Roof_1_0_0 0.0
B1_Roof_0.0

Block1:B1_Partition_2_0_0 90.0
B1_Partition_90.0

Block2:LR_Partition_4_0_10000 270.0
LR_Partition_270.0

Block1:B1_Wall_3_0_0 0.0
B1_Wall_0.0


which is what I wanted.

However, you all know that names are always cross referenced in a IDF file, thus what I am after is really a script capable of running a find and replace function throughout the IDF file.

Is there a way to run the string.replace(old_name, new_name) for an entire IDF file? My aim is that every string 'Block*:' is replaced with '' (so effectively deleted).

Thanks, Andrea

EDIT: The code:

surfaces = idf1.idfobjects['BUILDINGSURFACE:DETAILED']
s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm:
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)


does achieve the renaming I am after (where the input happens before Jamie Bull's substitution function).

However it does not seem to modify any object in the idf file (even though a saveas command is included at the end of the script). Why??

 4 retagged __AmirRoth__ 4388 ●5 ●16 http://bleedinggreenna...

### Using Eppy to replace recurring strings in an IDF file

Hello, I am trying to pre-process an IDF file (exported from DesignBuilder or OpenStudio) to use it with jEPlus.

As I am trying to 'assemble' a custom IDF file, using bits and pieces from different sources, I would like to manipulate an IDF, exported from DB, to combine it with objects that have customised names.

For surfaces, I managed to replace each surface name with a simpler name, the latter including the name of the zone, the type of surface and its azimuth.

The code:

s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm[:5]:
print '\n', name, azimuth
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)
print name


returns:

Block1:B1_GroundFloor_0_0_0 0.0
B1_GroundFloor_0.0

Block1:B1_Roof_1_0_0 0.0
B1_Roof_0.0

Block1:B1_Partition_2_0_0 90.0
B1_Partition_90.0

Block2:LR_Partition_4_0_10000 270.0
LR_Partition_270.0

Block1:B1_Wall_3_0_0 0.0
B1_Wall_0.0


which is what I wanted.

However, you all know that names are always cross referenced in a IDF file, thus what I am after is really a script capable of running a find and replace function throughout the IDF file.

Is there a way to run the string.replace(old_name, new_name) for an entire IDF file? My aim is that every string 'Block*:' is replaced with '' (so effectively deleted).

Thanks, Andrea

EDIT: The code:

surfaces = idf1.idfobjects['BUILDINGSURFACE:DETAILED']
s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm:
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)


does achieve the renaming I am after (where the input happens before Jamie Bull's substitution function).

However it does not seem to modify any object in the idf file (even though a saveas command is included at the end of the script). Why??

 5 retagged __AmirRoth__ 4388 ●5 ●16 http://bleedinggreenna...

### Using Eppy to replace recurring strings in an IDF file

Hello, I am trying to pre-process an IDF file (exported from DesignBuilder or OpenStudio) to use it with jEPlus.

As I am trying to 'assemble' a custom IDF file, using bits and pieces from different sources, I would like to manipulate an IDF, exported from DB, to combine it with objects that have customised names.

For surfaces, I managed to replace each surface name with a simpler name, the latter including the name of the zone, the type of surface and its azimuth.

The code:

s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm[:5]:
print '\n', name, azimuth
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)
print name


returns:

Block1:B1_GroundFloor_0_0_0 0.0
B1_GroundFloor_0.0

Block1:B1_Roof_1_0_0 0.0
B1_Roof_0.0

Block1:B1_Partition_2_0_0 90.0
B1_Partition_90.0

Block2:LR_Partition_4_0_10000 270.0
LR_Partition_270.0

Block1:B1_Wall_3_0_0 0.0
B1_Wall_0.0


which is what I wanted.

However, you all know that names are always cross referenced in a IDF file, thus what I am after is really a script capable of running a find and replace function throughout the IDF file.

Is there a way to run the string.replace(old_name, new_name) for an entire IDF file? My aim is that every string 'Block*:' is replaced with '' (so effectively deleted).

Thanks, Andrea

EDIT: The code:

surfaces = idf1.idfobjects['BUILDINGSURFACE:DETAILED']
s_names_azm = [(sf.Name, sf.azimuth) for sf in surfaces]
for name, azimuth in s_names_azm:
name = name.split(':',1)[1]
name = name.split('_',2)[0] + '_' + name.split('_',2)[1] + '_' + str(azimuth)


does achieve the renaming I am after (where the input happens before Jamie Bull's substitution function).

However it does not seem to modify any object in the idf file (even though a saveas command is included at the end of the script). Why??