Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question

Making a python module based on eppy

asked 2020-06-10 15:12:26 -0500

daniellosg gravatar image

updated 2020-06-10 18:23:12 -0500

Hi everyone, I’m a newb with Python and Eppy (apologies if I’m not using the proper programming terms), and I’ve been trying to make a class with different functions to work with Eppy. So, you can see in the files attached 2 modules (MyModuleV00, which works but not the way I’m trying to, and MyModuleV01, which is the one I’m trying to make work), 2 scripts using them (Working_with_MyModuleV00 and Working_with_MyModuleV01), and one IDF file to test it. So, what I’m trying to is to simplify Working_with_MyModuleV00 by avoiding the use of the variable idf1 in each function, or even avoiding all the lines above z=MyClass(…

image description

When I run Working_with_MyModuleV01 line to line, everything seems fine, however, when I open the new idf, there is no change with respect the older one. The functions should modify the existing People objects in the IDF, and add the object ZoneControl:Thermostat:OperativeTemperature for each zone in case there’s no such an object in the model. Can anyone help me please?

Thanks in advance.

Files attached:

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-06-13 17:28:43 -0500

updated 2020-06-13 22:40:30 -0500

Hi @daniellosg, I'm also a newbie with eppy. Out of curiosity I gave it a shot and looked into your codes. I think there is nothing wrong with eppy and you did very good on that. You made a newbie mistake in your class code! ;) That's why professional users don't answer your post. So here I am! :)

In __init__ method of your you have these codes which actually does nothing:


These are just some "variables" associated with the objects of your class. They have no functionality as they are just values! You can change them in other methods of your class but just calling them does nothing and that's why you see no change in the new idf that you generate.

My recommendation:

Instead of passing these to other methods, just pass the self.new_idf, self.old_idf, and self.filename to other methods:

 def __init__(self, filename_temp):
    fname1 = filename_temp+'.idf'
    self.old_idf = IDF(fname1)
    self.filename = filename_temp+'_pymod'
    self.new_idf = IDF(fname1)
    self.filename = filename_temp+'_pymod'

Using these attributes and updating self.new_idf at the end of each module will work for your purpose. I'm not sure if you need to use saveas() and self.filename since you will be working with idf itself. I think save() works bertter for you. Gool luck.

edit flag offensive delete link more


Hi @mehrdad,

Thank you so much! When I replaced the saveas function with save, the script worked perfectly.

Thanks again!!

daniellosg gravatar image daniellosg  ( 2020-06-14 23:52:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer


Question Tools



Asked: 2020-06-10 15:12:26 -0500

Seen: 196 times

Last updated: Jun 13 '20