Working with Python Scripts in PiXYZ Studio
Tutorial
·
intermediate
·
+10XP
·
30 mins
·
(13)
Unity Technologies

Python is at the core of PiXYZ Studio, and scripts are an effective way to leverage its power to perform time-consuming or repetitive tasks. In this tutorial you will learn how to script within PiXYZ Studio.
Languages available:
1. Working with Python Scripts in PiXYZ Studio
This tutorial has been verified using Unity 2019 LTS and PiXYZ 2020.1.1.8.
Python is at the core of PiXYZ Studio and scripts are an effective way to leverage its power to perform time-consuming or repetitive tasks. As you perform functions in PiXYZ Studio via the regular menus, in the Output pane you’ll see references made to their Python commands.
(Figure 01)

Figure 01: Many menu functions, such as Move nodes, are just front-end shortcuts for Python commands.
To learn more about PiXYZ Studio’s Python bindings, see the API documentation. PiXYZ Studio also ships with a number of Python scripts. To access them, select Open Sample Scripts Directory from the Help dropdown. (Figure 02)

Figure 02: The sample scripts are a great introduction to Python scripting in PiXYZ Studio.
Python scripts can be loaded by dragging and dropping them directly from Explorer into the Script pane. To toggle the visibility of the Script panel, select Script from the Windows dropdown. (Figure 03)

Figure 03: Enabling the Script pane
The Script panel consists of a row of buttons (Figure 04) above an area for scripts.


Figure 04: Script panel’s buttons, explained below
The buttons, from left to right:
- New File - Create a new file in a separate tab.
- Open A Script - Opens a window to load a saved Python script.
- Save Script - Saves the current script.
- Save Script to a File - Saves the current script to a new file.
- Execute the Script - Runs the entire script.
- Execute Selection - Runs only the selected lines.
- Interrupt Pixyz Process - Button activates if the current script contains the core.interruptionRequested() command, used to stop the execution of the script.
- Show Non-Printable Characters - Toggles the non-printable characters on and off.
- Open Sample Scripts Directory - Opens a window to the installation directory of the Sample Script Directory
2. Loading Scripts
You can either drag and drop a script from Windows Explorer into the Script panel, or click the Load Script button. (Figure 05)

Figure 05: Script Panel
3. Creating Scripts
You can create a script by clicking the New Script button (Figure 06)

Figure 06: New script button
4. Conclusion
Python in PiXYZ Studio is a powerful tool to add to your arsenal. Be sure to check out the sample scripts and the API documentation.