writing a pyhon script to semi-automate generation of CSV file for streamlines

I have a couple of simulation cases, that are very similar to each other.
For all the cases, I need to generate streamlines and export a csv file of the streamline data out for further processing.
Here is what I would like to be able to do:
I open one of the cases in paraView, and do all the required steps for generating the desired streamlines, then I save the state file as a python script.
Now I need to add a snippet (a csv writer of some kind) to the end of this state py file, to save the streamlines spreadsheet.
The end goal is to be able to use this py code for other cases, by just simply changing the path to the case, to semi-automate things, and write out the csv file without opening paraView.
Any help is appreciated.

Now I need to add a snippet (a csv writer of some kind) to the end of this state py file, to save the streamlines spreadsheet.

Use SaveData method

The end goal is to be able to use this py code for other cases, by just simply changing the path to the case, to semi-automate things, and write out the csv file without opening paraView.

This is the right way to go.

1 Like

I added

SaveData(“sample.csv”)

to the end of my python state file and ran it in pvpython. First it is giving me some errors like this:
( 22.655s) [paraview ] VisRTXBackend.cxx:42 WARN| VisRTX Error: Unsupported device

Also, I don’t know where the file would be saved?

( 22.655s) [paraview ] VisRTXBackend.cxx:42 WARN| VisRTX Error: Unsupported device

You can ignore this warning

Also, I don’t know where the file would be saved?

In the location you are running your script. Use an absolute path if you want to know.

1 Like

Here
https://docs.paraview.org/en/v5.8/UsersGuide/savingResults.html
it does not say how or where to specify the path.
Can you provide more details?

SaveData(“path/to/sample.csv”)

1 Like

Unfortunately, it is not saving any data.

SaveData("/home/glow/tmp/file.csv")

This is working great here.

You probably have an empty source.

When I type it in python prompt within the paraview app, it works;
but when I add it to the end of the my saved python state file (below SetActiveSource), and run it outside paraview in pvpython, nothing is saved.

can you tell me how I should execute my python state file in pvpython shell?
right now I am using:

exec(open(“D:\1_couetteFLow\stateStreamLine.py”).read())

For future reference, I had to use the following format to get it working:

SaveData(“D:\\1_couetteFLow\\sample.csv”)

2 Likes

Thank you both, I found this conversation interesting AND useful. And it occured at the perfect time.
Again, Thank you,
Bob