Getting Started#

Interacting with the application clients via Python API can be done in multiple ways. Direct execution of API calls can be performed using the IPython console, which can be activated in the View pull down menu by clicking on Python Window.

_images/view_python.png

Figure 1. View pulldown menu.

Once you are in the console, you can execute standard Python calls and import various packages you intend to work with:

  • import hw will give you access to the framework classes and functions (see hw Module).

  • import hm will give you access to HyperMesh client classes and functions (see hm Module).

  • import hm.entities will give you access to HyperMesh client entity classes (see hm.entities Module).

  • import hw.hv will import the HyperView classes (see hw.hv Module).

  • import hw.hg will import the HyperGraph and TableView classes (see hw.hg Module and hw.hg Module for TableView).

  • import hw.taskmanager will import the Task Manager classes (see hw.taskmanager Module).

  • import report will import the Reporting classes (see report Package).

  • import hwx.gui will import the GUI Toolkit classes (see GUI Toolkit).


_images/python_console.png

Figure 2. Python Window.

The Python 3.8.10 distribution included in the HyperMesh installation includes hundreds of popular packages and libraries like Pandas, NumPy, SciPy, TensorFlow, openpyxl, etc. You can retrieve a full list of accessible Python modules by calling help("modules")

Example Scripts#

Each documentation section has an Examples chapter dedicated to the corresponding Python package. Many of the examples use input data (model or result files) directly available in the Altair installation folder, but some of the examples require external files.

Before you begin exploring the examples and running them locally, download the following zip file and copy the file(s) to your working directory: example_files.

Running Python Scripts#

If you have a Python script you want to run in the application, you have the following options how to execute the code:

  • Via the File > Load > Python Script menu options

  • By drag & dropping the Python script file into the graphics area

  • Using the built-in IPython magic command run run <file_path> or %run <file_path>:

run "C:/MyPythonScripts/HyperView_report.py"

Python scripts can also be included in Extensions and linked to actions that can be exposed in a ribbon, a pulldown menu or a toolbar.