pvpython integrateVariables filter and extract data

Hello dear community,

I am running pvbatch so save the integrated data of some slices. I’ve tried a lot of things, based on what I could find in the forum. What I do is:


from paraview.simple import *
import numpy as np

PATH_PVD = "inlet.pvd"

# create a new 'PVD Reader'
inletpvd = PVDReader(registrationName='inlet.pvd', 
    FileName=PATH_PVD)

Ly = 0.008
grid = np.arange(-Ly/2, Ly/2 + dy, dy)
vel = []
for iy, y in enumerate(grid):
    # create a new 'Slice'
    slice1 = Slice(registrationName='Slice1', Input=inletpvd)
    slice1.SliceType.Origin = [0.0, y, 0.0]

    # create a new 'Integrate Variables'
    integrateVariables1 = IntegrateVariables(registrationName='IntegrateVariables1', Input=slice1)

    integrateVariables1.UpdatePipeline()
    
    # Create a new 'SpreadSheet View'
    spreadSheetView1 = CreateView('SpreadSheetView')       

    # create a new 'Pass Arrays'
    passArrays1 = PassArrays(Input=integrateVariables1)
    passArrays1.PointDataArrays = ['VELOC:1']    

    # update the view to ensure updated data information
    spreadSheetView1.Update()

    ss_data = servermanager.Fetch(passArrays1)    
    vel.append(ss_data.GetPointData().GetArray('VELOC:1').GetValue(0))
    print(vel)

However, I get an error with the servermanager

Traceback (most recent call last):
  File "3_save_integrated_slices_data.py", line 74, in <module>
    ss_data = servermanager.Fetch(passArrays1)    
  File "Software/ParaView-5.11.0-osmesa-MPI-Linux-Python3.9-x86_64/lib/python3.9/site-packages/paraview/servermanager.py", line 2468, in Fetch
    opc = op.NewInstance()
AttributeError: 'NoneType' object has no attribute 'NewInstance'

I have tried many other things but I thought, based on what I’ve seen in the forum, that this was the correct way. I am a bit of at a loss how to proceed, if anyone has a hint

Fixed it… leaving the solution in case anyone else needs it:

for iy, y in enumerate(grid):
    # create a new 'Slice'
    slice1 = Slice(registrationName='Slice1', Input=inletpvd)
    slice1.SliceType.Origin = [0.0, y, 0.0]

    # create a new 'Integrate Variables'
    integrateVariables1 = IntegrateVariables(registrationName='IntegrateVariables1', Input=slice1)
    integrateVariables1.UpdatePipeline()
    SetActiveSource(integrateVariables1)

    smdata = servermanager.Fetch(integrateVariables1)
    vel_y = smdata.GetPointData().GetArray('VELOC').GetValue(1)
    intgtd_data_np["u_y"][iy] = vel_y

    # Clean up
    Delete(slice1)
    del slice1
    Delete(integrateVariables1)
    del integrateVariables1
    del smdata
print(intgtd_data_np["u_y"])