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

EnergyPlus Python Plugin String Data Exchange

asked 2021-08-12 10:50:17 -0500

spqr's avatar

When using the EnerygPlus Python API in plugin mode, I need to transfer IDF specific config information to the plugin. This could be in the form of a filename for the plugin to then read from, or the API could transfer this config information as a string.

Looking at the datatransfer.py code, it appears the only method which will return non numeric or boolean data is: list_available_api_data_csv. I could set a variable name or schedule name to be the config filename, and then find it in this CSV, but this approach seems to be a bit of a hack.

I'm generating and running the IDF using eppy, so can programmatically set a text field which matches the IDF.

If it doesn't exist, this functionality may be a feature request for the Python API to make it more flexible.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-08-13 11:12:24 -0500

What information are you trying to share between the IDF to the script? If you're not already aware, there are a number of example Python scripts and corresponding IDFs included in the EnergyPlus example files (e.g. PythonPlugin...py).

edit flag offensive delete link more

Comments

I've worked through the different Python Plugin example files, and as far as I can tell, there isn't a way to do what I am trying to do. I'm trying to pass some sort of text / string information to the python plugin to provide it additional configuration information. This could be as simple as the IDF name which could then be parsed and used to load a separate config file. Or it could be a longer string which contains the config information (in a format such as JSON).

spqr's avatar spqr  ( 2021-08-22 21:31:39 -0500 )edit
0

answered 2023-07-03 10:11:26 -0500

whitewalker's avatar

Hi, I ran into the same problem and ended up with a bit of a 'hacky' solution as below.

TL;DR - use sys.path inside the plugin

All the paths present in the PythonPlugins:SearchPaths section of the idf are added by EnergyPlus to the Python environment variable. By default, this includes the idf location and the working directory.

You could do something like below to then figure out the idf directory from the ones returned by sys.path (not the most elegant solution, but it works :) ):

idf_dir = [p for p in sys.path if len(glob.glob(p + "\\*idf")) > 0][0]

Hope this helps!

edit flag offensive delete link more

Your Answer

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

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2021-08-12 10:50:17 -0500

Seen: 168 times

Last updated: Aug 13 '21