2

EnergyPlus Python Plugin String Data Exchange

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.

spqr's avatar
81
spqr
asked 2021-08-12 10:50:17 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

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

ericmartinpe's avatar
2.1k
ericmartinpe
answered 2021-08-13 11:12:24 -0500
edit flag offensive 0 remove flag delete link

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
add a comment see more comments
0

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!

whitewalker's avatar
1
whitewalker
answered 2023-07-03 10:11:26 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments