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):
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 $!EXTENDEDCOMMAND COMMANDPROCESSORID = "TecUtilServer" 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|"' WAIT = FALSE $!EndMacroFunction
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.
Note: Finding Python and adding it to the $!SYSTEM command (from step 2 above):
A) For Windows, on the command line, try this command:
For Linux, in terminal, try:
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|"'