I want to build a Python component to serve a specific objective in my LBT energy modeling script. I have described the inputs and output it in the attached image. I would greatly appreciate if any one of you python experts can create the code to make this work. I am learning python and understand the basics but I am confused as to how I can make it work in GH such as which libraries to import, what methods are available etc. If I could see this example then I can do more things myself. I can do this text editing outside GH but I want to make this one integrated script so that once I hit simulate the final modified IDF is generated and simulated.
Hi @RD , if that is all that you are interested in doing, you can do that without using any Gh libraries. You can just iterate line by line and replace the string. It will likely take a few seconds:
There might be a more elegant way to do this already with one of the Honeybee-Energy libraries. I use the LBNL-Frads library to do this (outside of gh).
Regards,
Sarith
PS: The gh file is attached, but cant guarantee that it will work on your system idfTxtRepl.gh (14.0 KB)
as my Rhino installation is old.
Thank you for taking the time to do this. Your code is more sophisticated and I actually was able to figure it out with help from ChatGPT!. Should have tried that sooner but I only thought of it after I posted here. TestScript_FindReplace.gh (13.8 KB)
The code is pretty straight forward and it works well for what I wanted. Can you tweak it it so that I can save the modified file as a copy and not overwrite the baseline file. I will supply a file name as an input or if its easier we can just append โv2โ to the original file name. I have attached the GH script as well.