CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Tecplot (https://www.cfd-online.com/Forums/tecplot/)
-   -   How to open data file in macro (https://www.cfd-online.com/Forums/tecplot/147296-how-open-data-file-macro.html)

lukas-777 January 17, 2015 13:28

How to open data file in macro
 
I have to handle many data files and on each file i have to perform similar functions for which i have already written a macro script. The name of the files are in the numerical order like

plunging_i=1_t=2.500e-03.plt , plunging_i=2_t=5.000e-03.plt, plunging_i=3_t=7.500e-03.plt, plunging_i=4_t=1.0000e-03.plt

#!MC 1100
# Created by Tecplot 360 build 12.0.0.3454
$!VarSet |MFBD| = 'C:\Users\Desktop'
$!READDATASET '"D:\DATA\plunging_i=1_t=2.500e-03.plt" '

Is it possible to open these files using macro loop instead of opening each file individually and then executing the same commands ??

scott_rumage January 23, 2015 17:28

I personally don’t know how to do what you are attempting in Tecplot 360. However this does appear to be a good fit for Tecplot Chorus, i.e. the loading in a series of data files and running a macro to produce a plot for each result.

Another benefit of Chorus is that one then can load in all the resulting plots into a matrix view to compare the results over a range of a given parameter.

You can learn more about Chorus at this link: http://www.tecplot.com/products/tecplot-chorus/

And you can download a trial version of Chorus at this link: http://www.tecplot.com/my/free-trial-software/ .

Regards,
Scott

lukas-777 January 24, 2015 09:56

And for Tecplot 360 would do the trick ?? He is working on it.

Durrell4 January 26, 2015 21:54

I would recommend a combination of Python and Tecplot360
 
Hi Lukas,

Chorus is perhaps not the tool for your application, I would suggest using python to read the files and launch Tecplot with a macro. If you need help writing the python code let me know and I can send you an example.

Durrell

Here is a script that I use to convert data from plt to szplt if you know python you could follow the code:

import os
import subprocess

tecplotPath = r"C:\Program Files\Tecplot\Tecplot 360 EX Beta\bin\tec360.exe"
directoryToCrawl = r"D:\TEMP\test"

def createWriteSZLMacroFile(filePath):
szlFileName = filePath.replace(".plt", ".szplt")
macroFilePath = r"writeSZL.mcr"
theFile = open(macroFilePath, "w")
theFile.write("#!MC 1410\n")
theFile.write("$!EXTENDEDCOMMAND\n")
theFile.write(" COMMANDPROCESSORID = 'Tecplot Subzone Data Tools'\n")
theFile.write(" COMMAND = 'WRITEDATASET FILENAME=\"%s\"'\n" %(szlFileName))
theFile.close()
return macroFilePath


def convertToSZL(fileName):
macroFilePath = createWriteSZLMacroFile(fileName)
commandArgs = [tecplotPath, fileName, "-b", "-p", macroFilePath]
subprocess.call(commandArgs)
os.unlink(macroFilePath)

def main():
for root, dirs, files in os.walk(directoryToCrawl):
for name in files:
fileName = os.path.join(root,name)
if fileName.endswith(".plt"):
convertToSZL(fileName)

if __name__ == '__main__':
main()


All times are GMT -4. The time now is 17:25.