impure functionexchange
Function that communicates with Python
Extends from Modelica.Icons.Function (Icon for functions).
Information
This function is a wrapper for
Buildings.Utilities.IO.Python_3_12.Functions.BaseClasses.exchange.
It adds the directory modelica://Buildings/Resources/Python-Sources
to the environment variable PYTHONPATH
prior to calling the function that exchanges data with Python.
After the function call, the PYTHONPATH is set back to what
it used to be when entering this function.
See
Buildings.Utilities.IO.Python_3_12.UsersGuide
for instructions, and
Buildings.Utilities.IO.Python_3_12.Functions.Examples
for examples.
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| String | moduleName | Name of the python module that contains the function | |
| String | functionName | moduleName | Name of the python function |
| BaseClasses.PythonObject | pytObj | Memory that holds the Python object | |
| Boolean | passPythonObject | Set to true if the Python function returns and receives an object, see User's Guide | |
| Real[max(1, nDblWri)] | dblWri | Double values to write | |
| Integer[max(1, nIntWri)] | intWri | Integer values to write | |
| String[max(1, nStrWri)] | strWri | String values to write | |
| Integer | nDblWri | Number of double values to write | |
| Integer | nDblRea | Number of double values to read | |
| Integer | nIntWri | Number of integer values to write | |
| Integer | nIntRea | Number of integer values to read | |
| Integer | nStrWri | Number of strings to write |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[max(1, nDblRea)] | dblRea | Double values returned by Python | |
| Integer[max(1, nIntRea)] | intRea | Integer values returned by Python |
Contents
| Name | Description |
|---|---|
| Pprotected |
Revisions
-
September 19, 2025, by Michael Wetter:
Updated to Python 3.12. -
August 27, 2021, by Michael Wetter:
Updated to Python 3.8. -
April 10, 2020, by Jianjun Hu and Michael Wetter:
Updated to Python 3.6. -
June 14, 2019, by Antoine Gautier and Michael Wetter:
Refactored for settingPYTHONPATHcorrectly independent of working directory. -
April 24, 2019, by Michael Wetter:
Refactored for gettingPYTHONPATH.
This is for #1421. -
May 2, 2013, by Michael Wetter:
First implementation.