Skip to main content
Skip table of contents

Python script (descriptor)

On a Windows machine, you need to install Python version 3 or higher and the py Python launcher

First select Descriptor as node type and then select Python script as the method. Select the python script file using the Browse button or type the path to the script file directly.

Parameters

Python file

Select the python file.

Python interpreter (optional)

Select a custom interpreter executable, empty will use py on Windows and python command on Linux and macOS.

Type

  • Object

    • Applies the python file content on the objects.

  • Pixels

    • Applies the python file content on the pixels.

Simple python script for a descriptor

PY
import sys

try:
    with open(sys.argv[1], "r") as f:
        frames = f.read().splitlines()

    count, totSum = 0, 0

    for frame in frames:
        pixels = [float(x) for x in frame.split(";")]
        totSum += sum(pixels)
        count += len(pixels)

    result = [totSum / count if count else 0]
    print(result)

except Exception as e:
    _, _, exc_tb = sys.exc_info()
    print(f"Error: {e}, at line {exc_tb.tb_lineno}")

Example input to the script

The input to the script is saved to a temp file and the absolute path to the file is passed as an argument to the script.

TEXT
1.0;1.5

Ending with an empty row.

Example output from the script

The output has to be printed from the python script to be returned to Breeze: print(result).

[1.25]

Brackets are optional.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.