# No cell data from vtkThreshold in Python plugin

**URL:** https://discourse.paraview.org/t/no-cell-data-from-vtkthreshold-in-python-plugin/4167
**Category:** ParaView Support
**Tags:** python, vtk
**Created:** [April 24, 2020, 6:00am UTC](https://discourse.paraview.org/t/no-cell-data-from-vtkthreshold-in-python-plugin/4167 "2020-04-24T06:00:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![wsherman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8797f3/32.png) [@wsherman](https://discourse.paraview.org/u/wsherman)
#### Post date: [April 24, 2020, 6:00am UTC](https://discourse.paraview.org/t/no-cell-data-from-vtkthreshold-in-python-plugin/4167/1 "2020-04-24T06:00:49Z")

</div>

I’m experimenting with a simple Python plugin that uses vtkThreshold but constrains the low and high values to a particular delta. The issue I’m having is that unlike the standard “Threshold” filter in ParaView, my simple plugin only outputs the `point` data, but not the `cell` data.

I think the most obvious consequence of this is that with the output from the ParaView built-in filter, I can render a Volume representation, whereas with my plugin, there is no option to render as a Volume.

I Googled around a bit, but wasn’t able to determine what the problem might be. One hypothesis I have is that the built-in filter may convert the point data to cell data after doing the processing.

Here’s my simple script, I used the Contour-Shrink example as my starting point,  
and I’ll add property parameters later, once I figure out my problem – or real  
ly once with the aid of the ParaView community, the problem is solved.

```auto
# Synchronized Threshold plugin (From ContourShrink example)
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from paraview.util.vtkAlgorithm import smproxy, smproperty, smdomain
import vtk # Note: added to ContourShrink example to make it work

@smproxy.filter(label="Threshold Sync")
@smproperty.input(name="Input")
@smdomain.datatype(dataTypes=["vtkDataSet"], composite_data_supported=False)
class ThresholdSync(VTKPythonAlgorithmBase):
  def __init__ (self):
      VTKPythonAlgorithmBase. __init__ (self)
      print "Loading Sync'd Threshold plugin"

  def RequestData(self, request, inInfo, outInfo):
      inp = vtk.vtkDataSet.GetData(inInfo[0])
      opt = vtk.vtkPolyData.GetData(outInfo)

      th = vtk.vtkThreshold()
      th.SetInputData(inp)
      print "number of point arrays " + str(inp.GetPointData().GetNumberOfArrays())
      print "number of cell arrays " + str(inp.GetCellData().GetNumberOfArrays())
      print "point data range: " + str(inp.GetPointData().GetArray(0).GetRange())
      th.ThresholdBetween(130.0, 150.0)
      th.Update() # Note: Update() not available in the Python Shell

      opt.ShallowCopy(th.GetOutput())
      return 1

```

I’m using the Wavelet source as the input with all default settings.

Thanks in advance, Bill

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [August 14, 2020, 7:54pm UTC](https://discourse.paraview.org/t/no-cell-data-from-vtkthreshold-in-python-plugin/4167/2 "2020-08-14T19:54:12Z")

</div>

Hi Bill,

You may have found the solution to this question already, but I’ll respond in any case. This is almost complete, but the output type needs to be specified to the output type of the `vtkThreshold` filter. You can do this in the call to `VTKPythonAlgorithmBase. __init__ ` by passing in the named parameter `outputType='vtkUnstructuredGrid'`.

With that change, your code is

```auto
# Synchronized Threshold plugin (From ContourShrink example)
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from paraview.util.vtkAlgorithm import smproxy, smproperty, smdomain
import vtk # Note: added to ContourShrink example to make it work

@smproxy.filter(label="Threshold Sync")
@smproperty.input(name="Input")
@smdomain.datatype(dataTypes=["vtkDataSet"], composite_data_supported=False)
class ThresholdSync(VTKPythonAlgorithmBase):
  def __init__ (self): 
      VTKPythonAlgorithmBase. __init__ (self, outputType='vtkUnstructuredGrid')
      print "Loading Sync'd Threshold plugin"

  def RequestData(self, request, inInfo, outInfo):
      inp = vtk.vtkDataSet.GetData(inInfo[0])
      opt = vtk.vtkUnstructuredGrid.GetData(outInfo)

      th = vtk.vtkThreshold()
      th.SetInputData(inp)
      print "number of point arrays " + str(inp.GetPointData().GetNumberOfArrays())
      print "number of cell arrays " + str(inp.GetCellData().GetNumberOfArrays())
      print "point data range: " + str(inp.GetPointData().GetArray(0).GetRange())
      th.ThresholdBetween(130.0, 150.0)
      th.Update() # Note: Update() not available in the Python Shell

      opt.ShallowCopy(th.GetOutput())
      return 1

```

With that change, you can volume render the output from this plugin.

HTH, Cory
