I want to access to the result of U using Python Shell after applying integrate variables filter. This is easy to be done manually but I want to do this using Python Shell as my further calculations require me to do some math.
To use Python Shell, I open Paraview and select my mesh regions and cell arrays. I press apply and after that, I run Python Shell and run my script. However, I get error as:
Traceback (most recent call last):
File "<string>", line 16, in <module>
AttributeError: 'NoneType' object has no attribute 'GetValue'
This is the script that I am using:
import paraview.simple as pvs
data = pvs.Wavelet()
my_slice = pvs.Slice(Input=data)
my_slice.SliceType = 'Plane'
my_slice.SliceType.Origin = [0.0, 0.0, 0.0]
my_slice.SliceType.Normal = [0.0, 1.0, 0.0]
my_slice.SliceType.Offset = 0.0
my_slice.Crinkleslice = 0
my_slice.Triangulatetheslice = 0
my_slice.SliceOffsetValues = [0.0]
iv = IntegrateVariables(Input=my_slice)
iv.UpdatePipeline()
data = servermanager.Fetch(iv)
numPoints=data.GetNumberOfCells()
print numPoints
U10=data.GetCellData().GetArray("U1").GetValue(1) # This is the line no. 16
print U10
I am doing something wrong. I checked Google to get some advice but I couldn't find my mistake. Can you help me to correct this? Thank you.
Edit for the solution:
I solved my problem and updated my code little bit. I wanted to edit my question for future-readers. The following code worked for me:
from paraview.simple import *
disp1OpenFOAM = FindSource('disp1.OpenFOAM')
slice1 = Slice(Input=disp1.OpenFOAM)
slice1.SliceType = 'Plane'
slice1.Crinkleslice = 0
slice1. Triangulatetheslice = 1
slice1.SliceOffsetValues = [0.0]
slice1.SliceType.Origin [0.0, 0.0023, 0.00]
slice1.SliceType.Normal [0.0, 1.0, 0.0]
integrateVariables1 = integrateVariables(Input=slice1)
DataSliceFile = paraview.servermanager.Fetch(integrateVariables1)
numCells = DataSliceFile.GetNumberOfCells()
U1 = [ ]
for x in range(numCells):
U1.append(DataSliceFile.GetCellData().GetArray('U1').GetValue(x))
print U1