Skip to content
Advertisement

Plot Over Line with pvpython

Good afternoon, I am trying to use the filter “Plot Over Line” of Paraview in a Python script. Basically, I want to:

  • Open the file “.vtu”;
  • Use the filter PlotOverLine for the velocity;
  • Save the data in a “.csv” file.

On internet, I found a possible way to do this, but it gives error if ran with pvpython (even if using the word “simple” before the commands):

from paraview import simple
import csv

flow = GetActiveSource()

plotOverLine1 = PlotOverLine(Input=flow, Source='High Resolution Line Source')

passArrays1 = PassArrays(Input=plotOverLine1)
passArrays1.PointDataArrays = ['U']

plotOverLine1.Source.Point1 = [0, 0, 0]
plotOverLine1.Source.Point2 = [0, 0.4, 0]
writer = CreateWriter('data.csv')
writer.UpdatePipeline()

Advertisement

Answer

First, you may report here you errors.

As you suggest, your script cannot work as is, you should change the import to from paraview.simple import *.

Also, your writer does not have explicit input. I recommend to use CreateWriter(filename='path', input=myInput), or, for a one shot write, SaveData(filename='path', input=myInput).

Finally, one way to produce such scripts is to use Tools / Start Trace menu option (with the default config). Then perform actions in the interface. Finally Tools / Stop Trace give you the python script corresponding to your actions.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement