5

Making a python module based on eppy

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: https://drive.google.com/file/d/1o8g5...

daniellosg's avatar
167
daniellosg
asked 2020-06-10 15:12:26 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2020-06-10 18:23:12 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

4

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 Mymodule01.py you have these codes which actually does nothing:

    self.idfo=idf1.idfobjects
    self.ridf=idf1.removeidfobject
    self.nidf=idf1.newidfobject
    self.sidf=idf1.saveas(self.filename+'.idf')

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'
    fname1=self.filename+'.idf'
    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.

Mehrdad Vojdani's avatar
1.1k
Mehrdad Vojdani
answered 2020-06-13 17:28:43 -0500, updated 2020-06-13 22:40:30 -0500
edit flag offensive 0 remove flag delete link

Comments

Hi @mehrdad,

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

Thanks again!!

daniellosg's avatar daniellosg (2020-06-14 23:52:46 -0500) edit
add a comment see more comments