9.7. Python Extension Files

EnSight supports user-written extensions written in Python. See the Produce Customized Access to Tools & Features section for details on this process. Once the user has developed an extension, they need to place it in a location where EnSight can find it. For user-specific extensions, one can place them in a subdirectory of the user's private preferences directory named extensions/user_defined. For example, if the private preferences directory is ~someuser/.ensight242 (under Linux), create a directory named ~someuser/.ensight242/extensions/user_defined and place the Python extension files in that directory (the files should use the CTOR comment header convention outlined in the Ansys EnSight How-To Manual.

For enterprise/multi-user extension installations, users should use the Product Extension mechanism. To simplify the distribution and installation of extensions and full graphical user interface replacements, the product extension was introduced. Product extensions are located in subdirectories of $CEI and the EnSight core scans for them right after loading the extensions located in the $CEI/ensight242/site_preferences/extensions/user_defined tree. EnSight looks for XML files named product.xml in the subdirectories of $CEI. An example from EnSight 9.1 is EnSight CFD, which is defined through the file $CEI/ensight91cfd/product.xml. A minimum product.xml would look like:

<?xml version="1.0" encoding="UTF-8"?> 
<product> 
<ensight_extension> 
<loader>EnSightCFDGUI.py</loader> 
<requires> 
<ensight_core> 
<minimum>9.1.0.0</minimum> 
<maximum>9.2.0.-1</maximum> 
</ensight_core> 
</requires> 
</ensight_extension> 
<ensight_extension> 
<loader>another_extension.py</loader> 
<translation>path/*.qm</translation> 
<documentation langid="">path/docs</documentation> 
<documentation langid="is">path/docs/iceland</documentation> 
<requires> 
<ensight_core> 
<minimum>9.1.0.0</minimum> 
<maximum>9.2.0.-1</maximum> 
</ensight_core> 
</requires> 
</ensight_extension> 
</product>

This file defines two extensions to EnSight (<ensight_extension>). The location of the Direct Load bootstrap Python file is specified by <loader> and must be a subdirectory of the directory where the product.xml file is located. This particular extension has a single dependency (<requires>) on the EnSight core Python interface (<ensight_core>). The allowed versions of the EnSight core are specified by the <minimum> and <maximum> tags respectively. In the example, this extension is allowed to load for all versions of EnSight number 9.1. Note that numbers are substituted for the (x) version tags on EnSight (for example, 9.1.0(c) corresponds to 9.1.0.2). All version comparisons are fieldwise numeric and matching the limits enables the extension. The second extension includes a pair of Qt .qm translation files that go along with the extension.


Note:  An extension block (<ensight_extension>) may have any number of <loader> and <translation> tags and multiple <requires> blocks that apply to all of the <loader> and <translation> tags in the block. Also, the <loader> and <translation> tags can include glob wildcards to specify multiple translation and Python loader files.


The <documentation> tag allows the product XML file to specify a directory where EnSight will look for it's documentation PDF files before it looks for them under $CEI/ensight*/docs. The tag also supports the langid="" attribute. This qualifies the path to a specific language. That path will only be used if EnSight is currently using the specified language. In the above example, path/docs will always be considered because the language id is "", but if the current EnSight language is set to Icelandic ("is"), the path/docs/iceland will be searched first. In all cases, the core EnSight docs directories will be searched, having failed all other matches.