9 Sep 2021

How to script the instantiation of a Python script object Xtra

This Xtra is a script template that can be used to instantiate a Python script object Xtra from the Python console or from a Python script.


The first two lines are dedicated to retrieve the AVIZO_LOCAL (or AMIRA_LOCAL) variable, which can be useful depending on the installation procedure of the Xtra you chose (see the Help section on that topic).

### Declaration of variable AVIZO_LOCAL (or AMIRA_LOCAL) ###
import _hx_core
# Retrieve AVIZO_LOCAL path value.
avizoLocal = _hx_core._tcl_interp("set app $AVIZO_LOCAL") 
### Instantiation of Xtra Python module ###
# Create the Python Script Object instance.
yourPythonModule = hx_project.create("HxPythonScriptObject")
yourPythonModule.name = "ModuleName"
# Set the path to the corresponding .pyscro file.
yourPythonModule.ports.filename.filenames = avizoLocal + "/share/python_script_objects/yourPythonScriptObject.pyscro"
# Load the .pyscro file.
yourPythonModule.ports.startStop.buttons[0].hit = 1
yourPythonModule.fire()
# Hide undesired ports.
yourPythonModule.ports.startStop.visible = 0
yourPythonModule.ports.filename.visible = 0