Page 1 of 1

Array equivalent in loop

Posted: Tue Apr 29, 2008 12:54 am
by chinu
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.

Re: Array equivalent in loop

Posted: Mon May 12, 2008 3:03 pm
by jim
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|