varlist from previous zone in macro

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

jentink
Experienced user
Posts: 15
Joined: Tue Jan 16, 2007 7:14 am
Location: hampton, va

varlist from previous zone in macro

Postby jentink » Mon Dec 22, 2014 2:54 pm

I want to read 2 zones, and have the new variable list be an appended list without having to know all the variables in each file.

For example, say I read in first zone with 23 variables. (byposition)

Then, I want to append a 2nd zone, keeping only 3 variables from the 2nd zone.
The only way i know how to do that now is with byname used for the 2nd read, but then my varnamelist must include the full list.

i was experimenting with python, and cat get a list containing the variable names in my first zone passed back in to my tecplot macro, but the format won't allow me to use that variable for my varnamelist in the 2nd read.


example code below:

------------------------------------------------------------------------------
test.mcr

$!EXTENDEDCOMMAND
COMMANDPROCESSORID = 'Python Utility'
COMMAND = 'LOADPYFILE NAME="array"'
#
$!READDATASET '"surfaces.plt" '
READDATAOPTION = NEW
RESETSTYLE = YES
INCLUDETEXT = NO
INCLUDEGEOM = NO
INCLUDECUSTOMLABELS = NO
ASSIGNSTRANDIDS = YES
INITIALPLOTTYPE = CARTESIAN3D
$!EXTENDEDCOMMAND COMMANDPROCESSORID='Python Utility' COMMAND='RUNPYFUNCTION MODULE="array" FUNCTION="makearray" ARGUMENTS="|numvars|,varlist"'
$!system "echo |varlist|"
#
$!VARSET |NZONES| = |NUMZONES|
$!VARSET |NZONESP1| = (|NZONES|+1)
#
$!READDATASET '"../loads.plt" '
READDATAOPTION = APPEND
RESETSTYLE = NO
INCLUDETEXT = NO
INCLUDEGEOM = NO
INCLUDECUSTOMLABELS = NO
VARLOADMODE = BYNAME
ASSIGNSTRANDIDS = YES
INITIALPLOTTYPE = CARTESIAN3D
VARNAMELIST = "|varlist|"

-------------------------------------------------------------------------------------------------------
array.py

Code: Select all

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

def TP_makearray(numv,vlist):
  varlist = []
  for i in range(1,numv):
    test = TecUtil.VarGetName(i)
    varlist.append(test[1])
  varlist = str(varlist)[1:-1]
  print varlist
  TecUtil.MacroSetMacroVar(vlist,varlist)
  return
[/code]

Return to “Tecplot Macro Language”

Who is online

Users browsing this forum: No registered users and 2 guests

cron