[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 590: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 646: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1068: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3843)
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1068: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3843)
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1068: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3843)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 113: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 113: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 113: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5133: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3843)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5133: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3843)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5133: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3843)
passing a list with commas from tecplot macro to python - Tecplot Talk

passing a list with commas from tecplot macro to python

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

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1107: count(): Parameter must be an array or an object that implements Countable
jentink
Experienced user
Posts: 15
Joined: Tue Jan 16, 2007 7:14 am
Location: hampton, va
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1107: count(): Parameter must be an array or an object that implements Countable

passing a list with commas from tecplot macro to python

Postby jentink » Wed Oct 26, 2011 6:59 pm

my eventual goal is to pass a list of active zones to a python script to access particular elements in the list of active zones. to test this, i'm trying a bit of code I found online, but no matter what i try, a list such as '1,2,5,9,21' will not pass correctly to the python module. if the list is all letters with no commas 'a b c ' or elements with a character as first letter 'a1 a2 ', it works. just numbers won't work and anything with commas won't work.

here's the test macro i'm using:
===================
#!MC 1300
# Created by Tecplot 360 build 13.1.0.15185
#
$!varset |activez| = 'a1 a2 '
$!system 'echo activez = |activez|'
$!EXTENDEDCOMMAND
COMMANDPROCESSORID = 'Python Utility'
COMMAND = 'LOADPYFILE NAME="test_array"'
$!EXTENDEDCOMMAND
COMMANDPROCESSORID='Python Utility'
COMMAND='RUNPYFUNCTION MODULE="test_array" FUNCTION="fetchcount" ARGUMENTS="|activez|,arraycnt"'
$!system 'echo numarray = |arraycnt|'

#
$!quit
===========================================

here i'm just trying to get a count of the list elements.

here's the python code i found online (file named test_array.py)
==============================================
#!/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 = count(s," ")
print "s = ",s
TecUtil.MacroSetMacroVar(dest,repr(i))
return
==========================================================

so long as my variable |activez| has no commas and each element begins with a character, it works.

if |activez| = '1,2,5,9,11', how do i get that to pass correctly to the python module?

thanks alot. this has been driving me crazy

User avatar
salter
Moderator
Posts: 188
Joined: Thu Dec 21, 2006 10:57 am
Location: NASA Langley Research Center
Contact:

Re: passing a list with commas from tecplot macro to python

Postby salter » Fri Oct 28, 2011 5:09 am

Steve...

Aerospace Research Engineer
Aerothermodynamics Branch
NASA Langley Research Center

jentink
Experienced user
Posts: 15
Joined: Tue Jan 16, 2007 7:14 am
Location: hampton, va
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1107: count(): Parameter must be an array or an object that implements Countable

Re: passing a list with commas from tecplot macro to python

Postby jentink » Fri Oct 28, 2011 5:21 am


Tecplot Support
Newbie
Posts: 1
Joined: Tue Aug 09, 2011 10:24 am
Location: Bellevue, WA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1107: count(): Parameter must be an array or an object that implements Countable

Re: passing a list with commas from tecplot macro to python

Postby Tecplot Support » Mon Oct 31, 2011 8:34 am


jentink
Experienced user
Posts: 15
Joined: Tue Jan 16, 2007 7:14 am
Location: hampton, va
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1107: count(): Parameter must be an array or an object that implements Countable

Re: passing a list with commas from tecplot macro to python

Postby jentink » Tue Nov 24, 2015 12:59 pm

been a loooonnng time, but I was looking for something else and came across this again. I've been using this for quite awhile with success. I just had to add a / to my list, with no commas. no idea why, but it works.

|activez| = '1 2 5 9 11 /'


[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1107: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1107: count(): Parameter must be an array or an object that implements Countable

Return to “Tecplot Macro Language”

Who is online

Users browsing this forum: No registered users and 0 guests