Miguel
Miguel

Reputation: 1363

Paraview: Get Points data from Integrate Variables

Using Python to interface with Paraview, I want to get the "Points" data from an integrate variable filter.

I tried the GetArray("Points") but it can't find it even though you can clearly see it in the GUI if you go to spreadsheet view.

My code is below. With the GUI approach I get for Point ID = 0 the array "Points" has three values (0.54475, -1.27142e-18, 4.23808e-19) which makes sense because the default arrow is symmetric in y and z.

Is there any way to get the value 0.54475 inside python?

MWE

#Import Paraview Libraries
#import sys
#sys.path.append('Path\\To\\Paraview\\bin\\Lib\\site-packages')
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'Arrow'
arrow1 = Arrow()
# create a new 'Integrate Variables'
integrateVariables1 = IntegrateVariables(Input=arrow1)
pdata = paraview.servermanager.Fetch(integrateVariables1).GetPointData()

print pdata.GetArray("Points") # prints None

Upvotes: 3

Views: 2984

Answers (1)

Stuart Buckingham
Stuart Buckingham

Reputation: 1774

You are very close. For all other arrays, you can access the value using the method you have written.

However VTK treats the point coordinates slightly differently, so the code you need for the point coordinates is:

arrow1 = Arrow()
integrateVariables1 = IntegrateVariables(Input=arrow1)
integrated_filter = paraview.servermanager.Fetch(integrateVariables1)
print integrated_filter.GetPoint(0)

This gives me: (0.5447500348091125, -1.2714243711743785e-18, 4.238081064918634e-19)

I would also suggest that you might want to do this in a Python Programmable Filter. Passing the filter from the server back to the client is not the best practice, and it is preferred to do all calculation on the server.

Upvotes: 4

Related Questions