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

TypeNameDefaultDescription
StringmoduleNameName of the python module that contains the function
StringfunctionNamemoduleNameName of the python function
BaseClasses.PythonObjectpytObjMemory that holds the Python object
BooleanpassPythonObjectSet to true if the Python function returns and receives an object, see User's Guide
Real[max(1, nDblWri)]dblWriDouble values to write
Integer[max(1, nIntWri)]intWriInteger values to write
String[max(1, nStrWri)]strWriString values to write
IntegernDblWriNumber of double values to write
IntegernDblReaNumber of double values to read
IntegernIntWriNumber of integer values to write
IntegernIntReaNumber of integer values to read
IntegernStrWriNumber of strings to write

Outputs

TypeNameDefaultDescription
Real[max(1, nDblRea)]dblReaDouble values returned by Python
Integer[max(1, nIntRea)]intReaInteger values returned by Python

Contents

NameDescription
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 setting PYTHONPATH correctly independent of working directory.
  • April 24, 2019, by Michael Wetter:
    Refactored for getting PYTHONPATH.
    This is for #1421.
  • May 2, 2013, by Michael Wetter:
    First implementation.