ARAP scripts can benefit from the huge library of code written in the Python language. From within an ARAP script, use the 'python' command to run a Python script. When Python scripts complete, control returns to the calling ARAP script.

Important Note: Python scripts run from the main thread of ARAP. That means they are "blocking" to the ARAP user interface, meaning the user interface will freeze and become non-responsive until the Python code completes. This means that users cannot stop a running script. You should take care in creating Python code so that it does not execute for too long OR includes a time out mechanism in case it runs longer than expected or it hangs up.

Syntax: python command option

Before using any 'python' commands, Python must be installed and ARAP must be setup to use it. See the Python Language section for details.

The available python commands are below..


Every 'python' command sets the value of variable PYTHONERROR to true if an error occurs. Review the system log for the nature of the error. Typical errors are either Python language syntax errors or run-time errors.



runstring

Syntax: python runstring "script text"

This command executes the python script contained in the second parameter. Usually this second parameter would be specified as a variable name (eg. $PYTHONSCRIPT) that was previously read from a file.

The three variables: PYTHONINPUT, PYTHONOUTPUT, and PYTHONCONSOLE are sent to and returned from the Python script. Each of these variables are equivalent, but have an intended purpose:

  • PYTHONINPUT - intended for passing an ARAP variable to the Python script
  • PYTHONOUTPUT - intended for returning a Python variable to the calling ARAP script
  • PYTHONCONSOLE - indented for returning the console output from the Python Script

For information on how to read and set these variables from within a Python script see Python Language.

runfile

Syntax: python runfile python.py

This command executes the python script contained in the file "python.py" which must be fully-qualified.

The three variables: PYTHONINPUT, PYTHONOUTPUT, and PYTHONCONSOLE are sent to and returned from the Python script. Each of these variables are equivalent, but have an intended purpose:

  • PYTHONINPUT - intended for passing an ARAP variable to the Python script
  • PYTHONOUTPUT - intended for returning a Python variable to the calling ARAP script
  • PYTHONCONSOLE - indented for returning the console output from the Python Script

For information on how to read and set these variables from within a Python script see Python Language.