< Back

Adding a PyTecplot Script to the Quick Macro Panel


Can I play a PyTecplot script from the Quick Macro Panel (QMP) in Tecplot?


Yes! This procedure describes how to add a PyTecplot script to your QMP using the Histogram.py (found in the python handy scripts of our GitHub):

1) Make sure PyTecplot is installed and updated, along with other modules used in your PyTecplot script (such as numpy). It is also recommended that you install the latest version of Tecplot 360.

2) For Histogram.py, add the following to the tecplot.mcr file. The tecplot.mcr file can be found in the Tecplot 360 installation folder (for example,  …\Tecplot\Tecplot 360 2019 R1\):

$!MacroFunction Name = "Histogram"
  ShowInMacroPanel = True
    COMMAND = R"(
        AcceptRequests = Yes
        ListenOnAddress = localhost
        ListenOnPort = 7600
  $!PromptForTextString |varname|
    Instructions = "Enter the variable name"
  $!PromptForTextString |numbins|
    Instructions = "Enter the number of bins"
  $!SYSTEM 'python -O "/path/to/py/script/Histogram.py" "|varname|" "|numbins|"'

Note: You may need to denote a specific version of Python, such as python3, in the $!SYSTEM command. If your system cannot find Python, try the procedure at the bottom of this article.
Additionally, a PyTecplot script that doesn’t take arguments doesn’t need the $!PromptForTextString |varname| or |numbins| commands.

3) Relaunch Tecplot 360, and the “Histogram” function should be located in the QMP.

4) Double-click Histogram.py, enter the requested variables, and an additional frame displaying a histogram should display in a new frame.


Histogram produced after tiling the frames with the DuctFlow.plt Tecplot example.

For an introduction on using PyTecplot, see this Quick Start video. If you have additional questions, contact Tecplot Support.



Note: Finding Python and adding it to the $!SYSTEM command (from step 2 above):

A)  For Windows, on the command line, try this command:

where python

For Linux, in terminal, try:

which python

See this example on Linux:

[user@CentOScomputer ~]$ which python3

B)  Then replace python in the System command with the path. See this example in Linux:

$!SYSTEM '/usr/bin/python3 -O "/path/to/py/script/Histogram.py" "|varname|" "|numbins|"'