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

Making a python module based on eppy

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

daniellosg gravatar image

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

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...

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
4

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

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

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.

edit flag offensive delete link more

Comments

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 -0600 )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

3 followers

Stats

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

Seen: 210 times

Last updated: Jun 13 '20