Script to extract data from Plot over Line

Hi everyone,

This is my first time posting here. I’ve been playing around with Paraview to automate some task to ease my Data analysis procedure.

I’m trying to extract the data of several files using the Plot over Line filter with a python macro, so far this is what I got.

from glob import glob
from paraview.simple import *

#get list of files
path = 'C:\\Jupyter\\Data\\vtks\\'
files = glob(path + '*.vtk')
scatView = CreateView('XYChartView')

for pattern in files:
    #load each file individually
    mesh = LegacyVTKReader(FileNames=[pattern],registrationName = pattern.split(path)[1])
    meshPointData = CellDatatoPointData(mesh)
    overLine = PlotOverLine(Input=meshPointData, Source='High Resolution Line Source')
    overLine.Source.Point1 = [0.0, 0.0, 0.0]
    overLine.Source.Point2 = [0.0, 0.0, 0.4]
    Show(overLine, scatView)

layout = GetLayoutByName("Layout #1")
AssignViewToLayout(view=scatView, layout=layout, hint=0)

This works fine, I get a plot with all the lines from several vtk files.

I would like to know how to export this data as a csv file. I tried using the GUI but that only exports one line at a time, which becomes quite exhausting when working with 200 files. Any advice would be highly appreciated.

Thanks!