PoserPython Scripts

The Scripts menu provides a hierarchical list of PoserPython scripts available for use within Poser. When you first launch Poser, this menu will list all of the PoserPython scripts that were included with your Poser installation. You have the option of placing additional Python scripts into the :Runtime:Python:PoserScripts: ScriptsMenu directory within your Poser installation; all scripts placed into this folder will be accessible within Poser from the Scripts menu.

Contents

  1. PoserPython Scripts
    1. Running PoserPython Scripts
      1. Running Your Script
      2. The Python Scripts Palette
      3. Using the Script Buttons

For more information about writing Python scripts and the codes and methods used in PoserPython, see the PoserPython Methods Manual.

Running PoserPython Scripts

Poser includes a simple graphical user interface that allows you to execute Python scripts by pressing a button. You can customize the Python Scripts palette and, in addition, you can run Python scripts directly.

Running Your Script

You can run your script directly or via the Poser Scripts menu or palette, all of which are described in Using PoserPython in your Poser Reference Manual.

Running Python Scripts Directly

The Poser Python Scripts palette keeps your frequently used scripts close by for easy use. However, you can run any script you wish by selecting File > Run Python Script to open the standard operating system navigation dialog. Locate the script you wish to run by browsing your folders and directories, then press Open to run the script.

Running Python Scripts from Pose (PZ2) Files

You can also add commands in pose files that will call scripts to be run. For example, pose files have been able to call a Python script by adding the following line in the pose (PZ2) file:

runPythonScript "runtime:path:to:script.py"

runPythonScript has no arguments that can be passed to script.py, meaning that if you have five poses doing the same thing with only one difference, the developer has to make five copies of that script where only one line is different in each. 

However, the runPythonScriptEx variant allows you to pass an argument to the script. For example, in script.py, the variable sys.argv[1] will be equal to "apples" as it would be if script.py were run from a command line. The syntax is as follows

runPythonScriptEx "runtime:path:to:script.py" apples

Alternately, you can access your script directly from the Poser Scripts menu.

The Python Scripts Palette

Launch the Python Scripts palette within Poser by selecting Window > Python Scripts.

Python Scripts palette.

Clicking some of the buttons will display a submenu of buttons within the Python Scripts palette. This is just one example of how Python scripts can be used to customize Poser. You can write scripts that will open button menus and submenus. If you are curious, you can open one of the existing submenu scripts to see how this is done.

Using the Script Buttons

To run a script, simply press the desired button and the script will execute automatically.

Assigning Buttons Within the Console

Unassigned buttons do not have a label. An ellipsis (...) appears in unassigned buttons to mark their availability. To assign a script to a button, simply press the mouse on the button and locate the desired script (.py file) using the standard operating system file picker. Once you have located the desired script, select it and press Open.

Editing Scripts Within the Console

You can edit scripts assigned to a Poser Python Scripts palette button by pressing and holding [CTRL] while clicking the button assigned to the script you wish to edit. This opens the script within your operating system’s default text editor for easy modification. Save your changes as appropriate for the editor you are using. You may also select your own editor via the General Preferences dialog, which can be obtained by choosing Edit > General Preferences as described in .

Unassigning/Reassigning Buttons Within the Console

To reassign a button to a different Python script, you must first delete its current assignment and then assign the new script to it. Do this by pressing and holding [OPT]/[ALT] while clicking the button you wish to unassign. If you wish to assign the newly freed up button to a different script, do so as outlined above.

© 2020-2023 Bondware, Inc. Last updated March 29, 2023