PyTecplot

TecPLUS™ subscribers are given access to PyTecplot, a high level API that connects your Python script to the power of the Tecplot 360 visualization engine. Familiarity with Tecplot 360 and the Tecplot 360 macro language is helpful, but not required.

PyTecplot requires 64-bit Python versions 2.7 or 3.4+ and Tecplot 360 version 2017 R1 or later with TecPLUS™ maintenance service. PyTecplot does not support 32 bit Python.

Please refer to the PyTecplot Guide for installation instructions, environment setup, and the full reference manual. The sections below refer only to the User Interface portions of PyTecplot located in Tecplot 360.

PyTecplot Recording

Tecplot 360’s PyTecplot Recorder records a Python script as you perform a sequence of actions interactively. Scripts are PyTecplot Python (.py) format. PyTecplot Python scripts run outside of Tecplot 360, and may be run from either the command line or any Python IDE.

After recording your script, you can edit your script file with a plain text editor to remove redundant operations, compress repetitive actions into loops, replace references to files with variable names, and otherwise modify the script to make it more generic and flexible.

To record a macro with the PyTecplot Recorder dialog, select "Record PyTecplot" from the Scripting menu. Specify a file name in the Write Script (.py) dialog and click Save to initiate the recording. The Macro Recorder dialog remains open during the recording session.

Auto Redraw is disabled during recording. If necessary, you can manually redraw your plot by clicking the Redraw button in the Plot sidebar.

For information on the Macro Recorder dialog, see Macro Creation.

PyTecplot Connections

The PyTecplot Connections dialog allows a remote Python instance to control the GUI and interact with the loaded data. Currently, the only available client for this server is PyTecplot, the "tecplot" Python module available on Python’s official package repository, PyPI.

Server Configuration

To allow the server to process incoming requests, go to Tecplot 360’s main menu and choose Scripting→PyTecplot Connections…​ and the PyTecplot Connections dialog will appear:

pytecplot connections

Clicking on the checkbox next to "Accept connections" will enable the server immediately. If the chosen port is already in use by another process, even by another running instance of Tecplot 360, the following error message will be shown:

pytecplot connections warning

In this case, you may choose another unused port number and attempt to re-enable the "Accept connections" option.

By default, the TecUtil Server will only listen for requests from localhost. Unchecking the "Listen to localhost only" option will cause the server to process incoming requests from any remote machine, subject to the firewall and security settings of the computer running Tecplot 360.

Connecting from the PyTecplot Client Script

To connect to the server from a Python script, you must have the PyTecplot python package installed. Please see PyTecplot’s documentation for detailed instructions on how to get started with PyTecplot. In the Python script, use the tecplot.session.connect() method to connect to the running instance of Tecplot 360:

import tecplot
tecplot.session.connect(port=7600)

Once connected, the Python script will continue to run and the Tecplot 360 will be updated in real-time.

Activating Server with a Macro File

To activate the TecUtil Server addon in Tecplot 360 with a macro, add this macro command to a separate .mcr file:

$!EXTENDEDCOMMAND
 COMMANDPROCESSORID = "TecUtilServer"
 COMMAND = R"(
 AcceptRequests = Yes
 ListenOnAddress = localhost
 ListenOnPort = 7600
 )"

To use this function on start-up, simply play the macro file as you launch Tecplot 360:

tec360 -p startConnector.mcr