Tecplot Tutorial

TECPLOT is a very nice program it is much easier to use, and produces much nicer output that – ABAQUS/CAE. Actually TECPLOT 360 will read an ABAQUS.odb file and you might like to explore this capability even for plotting ABAQUS results. Interpreting the input file. For Windows users, there is a tutorial which describes how to configure an xserver client such as xming to allow for the remote display of the Tecplot gui. This describes how to set up X11 tunneling which is required to allow the remote gui to be processed by the xserver client.

This blog on Tecplot Macro Tutorials was written from a webinar entitled Ask the Expert About Tecplot 360 hosted by Scott Fowler, Tecplot 360 Product Manager. We received numerous questions about Tecplot macros and this blog pulls our macro resources together in one place.

What is a Tecplot macro? A Tecplot macro is a set of instructions, called macro commands, that perform actions in Tecplot 360. Macro commands can be used to accomplish virtually any task that can be done via the Tecplot 360 interface, offering an easy way to automate Tecplot 360 processes.

Tecplot Macro Tutorials

Macro Resources

Tecplot Tutorial
  • Tecplot 360 Scripting Guide
    (also available in the Tecplot 360 User Interface)

We recommend that you download the macros, datasets and layout files used in the descriptions below. If you do not already have Tecplot 360 running, you can download a Free Trial.

Using a Macro to Produce Transient Plots

This macro reads and edits different time steps and produces transient plots. This macro first finds out how many time steps are in your dataset, then it loops over those time steps. At each time step the current time step is set and an image is exported. That’s It!

export_over_time.mcr
$!EXTENDEDCOMMAND COMMANDPROCESSORID='extend time mcr' COMMAND='QUERY.NUMTIMESTEPS NUMTIMESTEPS'
$!LOOP |NUMTIMESTEPS|
$!EXTENDEDCOMMAND COMMANDPROCESSORID='extend time mcr' COMMAND='SET.CURTIMESTEP |LOOP|'
$!EXPORTSETUP EXPORTFORMAT = PNG
$!EXPORTSETUP EXPORTFNAME = 'FILE_|LOOP|.png'
$!EXPORT
$!ENDLOOP

Extend Time Macro Addon

The Extend Time Macro add-on simplifies the macro interface by allowing you to use a simple loop to query the number of solution times in the dataset and advance the time step. This differs from the native Tecplot macro language as it does not require that you know the solution time of your data.

This add-on uses a different algorithm than Tecplot 360 EX for sorting the solution times. Because Tecplot 360 combines time steps that are sufficiently close together, the number of time steps reported by this add-on may differ from the number of time steps reported by Tecplot 360.

You can load this addon by adding the following line to your tecplot.add File. See chapters 31 – 3.5 and 31 – 1.2 in the Tecplot 360 User’s Manual.

$!LoadAddOn 'tecutilscript_extendtime.mcr'

Converting Binary Files to ASCII

A question asked during the webinar was “How do I convert TEC files to binary?” The .tec file extension has been adopted by the greater Tecplot community. These files are usually ASCII, but in this case, the TEC file was a binary file. So, the question becomes “How do I convert from binary to ASCII?” Well, that’s easy!

Let’s backtrack for a moment and review the canonical Tecplot file extensions:

Tecplot
  • PLT (.plt) – Tecplot binary format.
  • DAT (.dat) – Tecplot ASCII format.
  • SZL (.szplt) – Tecplot Subzone Load-on-demand binary format. This format allows you to load large volume metric grids with very little RAM.
Tecplot

» Read the “Comparison of Tecplot Data File Formats” blog on Tecplot file types.

We don’t have a standalone utility to convert binary files to ASCII, but you can do it using the macro binary_to_ascii.mcr (also included in the ZIP file mentioned above). In the macro, you simply use the ReadDataSet command and then a WriteDataSet command.

binary_to_ascii.mcr
#!MC 1410
$!ReadDataSet 'VortexShedding.plt' '
ReadDataOption = New
ResetStyle = No
VarLoadMode = ByName
AssignStrandIDs = Yes
$!WriteDataSet 'VortexShedding.dat'
IncludeText = No
IncludeGeom = No
IncludeCustomLabels = No
IncludeDataShareLinkage = Yes
Binary = No
UsePointFormat = No
Precision = 9
TecplotVersionToWrite = TecplotCurrent

From the command line you would call tec360.exe and pass this macro. Note that the file names in the macro need to be hard coded.>tec360 -b -p binary_to_ascii.mcr
Here a plug for the power of Python!
Using PyTecplot to convert files, in this case binary to ASCII, is so much simpler as you can see in these few lines of code. This Python script (binary_to_ascii.py)is in the ZIP file mentioned above.

import tecplot as tp
tp.data.load_tecplot(‘mybinaryfile.plt’)​
tp.data.save_tecplot_ascii(‘myasciifile.dat’)​

Converting ASCII Files to Binary

Another user wanted to convert ASCII files to binary.

You can use a utility called Preplot. Preplot is included with Tecplot 360 and it’s located in the bin directory in the Tecplot 360 installation. You just pass it an ASCII file (.dat) and tell it the output file name. Preplot will do the conversion for you.

> preplot myasciifile.dat mybinaryfile.plt

» Watch the video tutorial, Preplot and SZL Convert Tools.
» Read the Tecplot 360 User’s Manual.
» Reference the Data Format Guide.

A note about ASCII data, whenever Tecplot 360 loads an ASCII file we actually convert it to binary as it’s being loaded. Because of this, it is in your best interest, if you need to load that file over and over, to do the conversion only once. You will save yourself a lot of time!

Placing Streamlines and Streaklines Using Macros

During the webinar, one user was trying to create an arc of streamlines (which we call streamtraces in Tecplot 360). This is not possible using the onscreen “Rake” tool! The Rake tool only places straight lines of streamlines.

If you want to define an arc of streamlines, the best way to do it would be with PyTecplot (but that will be the topic of a future blog). I explain here how to do it with a Tecplot macro.

Here is the Tecplot macro for placing the streamtrace object associated with the frame. In the code below, I’m adding a streamtrace, defining it as a volume line, setting the direction to “both” (default is forward), and placing it at X= 0.5, Y=0.5, Z=0.5. You can create an arc by having multiple of these add commands at different locations.

$!STREAMTRACE ADD ​
NUMPTS = 1 ​
STREAMTYPE = VolumeLine​
STREAMDIRECTION = Both​
STARTPOS { X = 0.5 Y = 0.5 Z = 0.5 }​

Loading a Saved Frame Style Without the Position

How do I share data across frames without having to reload the data? In this example, I want to tile frames and then save the style from the upper left plot and load it into the lower right frame. You can do this, but not directly in the Tecplot 360 user interface. We will use a macro to do this (It can also be done with PyTecplot).

Copy Frame Style Steps

  1. First, create a new frame (click the Frame icon and draw a new frame). Then change the plot type to 2D Cartesian. (Now I could easily click on the upper left frame and save the frame style (Frame>Save Frame Style). Then, I could click in the new frame and load the frame style, but that will also copy the frame size and position which will overlay the original position. I want to retain the position. So, I don’t want to do it this way.)
  2. Drag and drop the copy_frame_style.mcr macro (from the ZIP file above) onto the Tecplot 360 user interface. Two new entries will appear in the Quick Macro Panel: “Copy frame Style” and “Paste frame Style.” Be sure the stylesheet directory in the macro is valid (C:TEMPtemp_style.sty”).
  3. Click on the frame you want to copy, click the Quick Macro “Copy frame Style” and click Play (or simply double-click on the macro name).
  4. Select the new frame and double click on the “Paste frame Style” macro.
  5. Voila! You now have a new frame with the same style. This is one of the macros I use most often.

Tecplot Tutorial Pdf

Copy Frame Style Video Tutorial

The magic is in the macro’s last command “INCLUDEFRAMESIZEANDPOSITION=NO,” which loads the frame style but ignores the position.

Making Macros Persistent in Tecplot 360

Tecplot Animation Tutorial

Tecplot tutorial

If you want these macro functions always available, you can put them in the tecplot.mcr file (located in Tecplot 360 installation directory).

If you are sharing the Tecplot 360 installation, for example in a Linux environment, you can put the “.tecplot.mcr” file in your Linux home directory so as not to impact other users on your network.

Tecplot Focus Tutorial

Tecplot Tutorial

Tecplot Tutorial Pdf

Learn more about macros in the Tecplot 360 User’s Manual (search for “tecplot.mcr”).