Array equivalent in loop

Tecplot's automation language

Python scripts were supported in the alpha version for Legacy 360 (2013). Python inquiries in 2017 should be directed to the PyTecplot Forum.

Moderators: davetaflin, salter, steve, jprenaud, straton, Chris Idso

chinu
Newbie
Posts: 4
Joined: Mon Apr 28, 2008 11:45 am
Location: Bangalore
Contact:

Array equivalent in loop

Postby chinu » Tue Apr 29, 2008 12:54 am

My data set has multiple variables which I would like to contour plot one by one, and export as an image. I couldn't find the equivalent of an array in the tecplot scripting guide. Can someone shed light please?

What I have is:

$!VarSet |CONTVARS| = '"X" "Y" "Z" "axial-velocity" "radial-velocity" "tangential-velocity"'

which I pass on to READDATASET. I want contours of axial, radial and tangential velocities. What I want is something like

$! LOOP [[ over velocity components ]]
$! VarSet |VARCNT| = 3 + |LOOP|
$!GLOBALCONTOUR 1 VAR = |VARCNT|
$!EXPORTSETUP EXPORTFNAME = 'export.bmp'
$!EXPORT
EXPORTREGION = ALLFRAMES
$!ENDLOOP

I need a valid replacement for the term within [[...]] in the loop statement line.

jim

Re: Array equivalent in loop

Postby jim » Mon May 12, 2008 3:03 pm

The macro language does not support any notion of array. Can you use nested loops?

Alternatively, if the task is to figure out how many parameters are contained in CONTVARS, you could use python. For example, suppose you did this:

Code: Select all

$!VARSET |CONTVARS| = "X Y Z axial-velocity radial-velocity"
$!EXTENDEDCOMMAND COMMANDPROCESSORID = 'Python Utility' COMMAND='RUNPYFUNCTION MODULE="jim" FUNCTION="fetchcount" ARGUMENTS="|CONTVARS|,arraycnt"


With this python script:

Code: Select all

#!/usr/bin/env python
import TecUtil
import TecVals
import string
from string import split
from string import count

def TP_fetchelement(s,i,dest):
  somearray = split(s)
  # tecplot indexes arrays from 1; python uses 0
  TecUtil.MacroSetMacroVar(dest,somearray[i-1])
  return

def TP_fetchcount(s,dest):
  i = 1 + count(s,' ')
  TecUtil.MacroSetMacroVar(dest,repr(i))
  return


The result would be put into the variable accessed from the macro language |arraycnt|. Thus, your loop would then start like:

Code: Select all

$!LOOP |arraycnt|


Return to “Tecplot Macro Language”

Who is online

Users browsing this forum: No registered users and 0 guests