Replace Strings Function Energy+

Hi everyone,

I’m trying to create a “ReplaceStrings” function in the EnergyPlus Laucher component. The goal is to replace some lines of the idf file directly from Grasshopper to centralized all the simulation.

I added two inputs in the EnergyPlus component, one for the text to replace, and one for the new text :

Then I wrote this code :

The code seems right since it don’t return any error but when I check the idf file, the text to replace didn’t changed :

I tried to use the code on an other idf file than the one created by the EnergyPlus component (I just changed the file adress) :

And it works on this file :

The code works great but it doesn’t work on the file created by honeybee. I do not understand because I wrote the code after the creation of the idf file (after " idfFile.close() ") so the code should work.

If anybody have some ideas on this it would be very helpful, thanks ! (621.6 KB)


This is one of the inputs i never used, but i can see that the updated version of the Run E+ component is no longer supporting those inputs. Probably they didn’t work well before … but can’t tell for sure.
Just wondering why you don’t change parametrically the HB_EPOpaqueMat component instead?

I’m just testing this replace function with the opaque materials because I think it’s a good way to test it.

I just found a solution here. First, I changed the code because the other one wasn’t working great :

The second problem was that the input is a list of lines, so the EnergyPlus component was running as much simulations as lines in the list, each time overwriting the previous idf file. Because of that, there was just the last line who was edited (the others was overwrited by the simulations). To solve this problem, I separated the code from the EnergyPlus component and put it in pythonScript component. Then I used the Re-run E+ component to lauch the simulation after the editing of the idf file.

It seems to work great so I upload the gh file here, can be useful for other people. (580.5 KB)

I didn’t already use it a lot so it can cause errors, I’m not sure of that. First one is that the code handle the editing line by line, so if there are similar multiple lines, it will editing all the lines. For example, here, if there are multiple materials with a thickness of 0.25 they will all be replace by 1 (not just the “WALLBETON”). Don’t know how to solve that.


very useful ghpython component @antoine.abelard!