The Scripting API Python Wrapper exposes features of the API to your Scripting environment and simplifies common procedures to make it easier to write HyperX Scripts.
Tip
Collier Aerospace recommends utilizing this Wrapper over directly referencing the API.
To begin use, first install the Python package. It is important to install the version of the Python package that matches your installed version of HyperX. The below image shows a user installing version 2023.2.6 of the wrapper in their command prompt.
The Python package is also included in the HyperX install as of version 2024.1.8. This means that access to the Internet is not required to install the Python package. It is shipped as a Python wheel file, and is located in: "$(InstallDir)\Scripting\Python\hyperx<HYPERX VERSION>-py3-none-any.whl". It can be installed using pip by pointing to the location of the .whl file:
Note
If bugs in the Wrapper are found for a given version, they will be fixed and published with a new patch version; e.g., if a bug is present in version 2023.2.6 of the wrapper, subsequent version 2023.2.6.1 will be published containing the patch for this bug.
To use the API Python Wrapper in a Script:
-
Import the
hyperxpackage in a Script file. -
Optionally, alias the package name to shorten calls to the API.
-
If writing a Script Runner compatible Script, pass input parameter from the
Run(database_)method into thehx.Applicationconstructor to officially wrap the Database object. If writing a script which interacts with HyperX externally, use thehx.Open(pathToDatabase)method to return an already-wrapped Database object (Easy Database Opening).
# import package with optional alias
import hyperx as hx
def Run(database_):
# pass input database into hx.Appliication constructor to officially
# wrap the database project
db = hx.Application(database_)
Documentation for the API Wrapper corresponding to the latest HyperX release is available on our API Documentation Portal.
Importing the hyperx package enables autocomplete when writing Script calls. For example, in the widely used code editor VS Code, typing ctrl+space will provide suggestions for method parameters and return types, enum members, etc.
Enums in the HyperX.Types and HyperX.Scripting namespace can be accessed in hyperx.types and hyperx.api respectively.
Doc strings are exposed to the code editor to provide documentation at a glance for methods and properties where available.
When running a Script outside of the Script Runner, the hyperx package provides a method for opening HyperX Databases (Open(databasePath)) which returns a pre-wrapped version of the Application.
The hyperx package also allows indexing into collection classes using bracket notation.
The hyperx package automatically converts Python collections to C# data types leading to more streamlined Script files. The images below demonstrate the code to create a Panel Segment. The top image is what is needed with just the Scripting API and the bottom image utilizes the automatic data type conversion available through the Scripting API Wrapper to perform the same operation with significantly fewer lines of code.