issue with SelectCells

I am having an issue extracting data with the following code (Using PV5.7). SelectPoints() works fine. SelectCells() complains, although I can create an equivalent selection with 'Find Data". The error message is:

(   1.455s) [paraview        ]  vtkPythonSelector.cxx:76    WARN| vtkPythonSelector (0x5620e4686e60): Could not invoke 'python_selector.execute()'
Error: Failed to evaluate Expression 'RTData <= 100'. The following exception stack should provide additional developer specific information. This typically implies a malformed expression. Verify that the expression is valid.

Traceback (most recent call last):
  File "/local/apps/ParaView/5.7/lib/python3.7/site-packages/paraview/detail/python_selector.py", line 79, in execute
    maskArray = calculator.compute(inputs, query, ns=elocals)
  File "/local/apps/ParaView/5.7/lib/python3.7/site-packages/paraview/detail/calculator.py", line 143, in compute
    retVal = eval(expression, globals(), mylocals)
  File "<string>", line 1, in <module>
NameError: name 'RTData' is not defined
Error: Failed to evaluate Expression 'RTData <= 100'. The following exception stack should provide additional developer specific information. This typically implies a malformed expression. Verify that the expression is valid.

The code is here:

from paraview.simple import *

w = Wavelet()
w.UpdatePipeline()

w2 = PointDatatoCellData(Input=w)
w2.PassPointData = 1
#w2.ProcessAllArrays = 1
w2.UpdatePipeline()

cdi = w2.GetCellDataInformation()
assert cdi.keys()[0] == 'RTData'

selection=SelectPoints()
selection.QueryString="RTData <= 100"
selection.FieldType = 'POINT'
selection.UpdatePipelineInformation()

# create a new 'Extract Selection'
mySelection = ExtractSelection(Input=w2, Selection=selection)
mySelection.UpdatePipeline()
Show(mySelection)

selection2=SelectCells()
selection2.QueryString="RTData <= 100"
selection2.FieldType = 'CELL'
selection2.UpdatePipelineInformation()

# create a new 'Extract Selection'
mySelection2 = ExtractSelection(Input=w, Selection=selection2)
mySelection2.UpdatePipeline()
Show(mySelection2)

With the script in the order you have posted, the
selection2=SelectCells() operation is happening on the active source, which looks like it might be the selection object. Try specifying the input to the SelectCells() filter, or re-ordering things so that w2 is created right before selection2.

HTH,

Aron

Thanks @aron.helser. That did the trick. The lack of many examples and nobody to watch over my shoulder…

I also corrected my last ExtractSelection(Input=w2, Selection=selection2) with the correct Input, i.e. w2

problem solved. Back to the real data.

1 Like

@jfavre FYI in master there is new selection API to make this simpler. See https://gitlab.kitware.com/paraview/paraview/blob/master/Wrapping/Python/paraview/selection.py for details.