# Clipping by Scalar from CellData / vtkClipDataSet / Python

**URL:** https://discourse.vtk.org/t/clipping-by-scalar-from-celldata-vtkclipdataset-python/4724
**Category:** Support
**Created:** [November 24, 2020, 3:31pm UTC](https://discourse.vtk.org/t/clipping-by-scalar-from-celldata-vtkclipdataset-python/4724 "2020-11-24T15:31:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jason1](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/b19c9b/32.png) [@Jason1](https://discourse.vtk.org/u/Jason1)
#### Post date: [November 24, 2020, 3:31pm UTC](https://discourse.vtk.org/t/clipping-by-scalar-from-celldata-vtkclipdataset-python/4724/1 "2020-11-24T15:31:40Z")

</div>

Hello,  
I want to read a .vtu file and clip it so that I can work with the necessary data only. To do so the .vtu contains CellData with a tag which I can use to clip by scalars. After some searching I came to the following code but it seems that clip.GetOutput( ) is empty. Can you help me?  
I tried a lot but since I am new to VTK I can’t find a solution.

#file path  
filename = ‘test.vtu’

#read vtk returns vtkreader (a function I wrote in an other module)  
file = f.readData( filename )

#clip only necessary data  
tags = file.GetOutput( ).GetCellData( ).GetArray( ‘Tag’ )  
file.GetOutput( ).GetCellData( ).SetScalars( tags )

clip = vtk.vtkClipDataSet( )  
clip.SetInputData( file.GetOutput( ) )  
clip.SetValue( 100 )  
clip.SetInsideOut( True )  
clip.Update( )

---

<div class="post-metadata">

### Author: ![Joachim\_P](https://discourse.vtk.org/user_avatar/discourse.vtk.org/joachim_p/32/3272_2.png) [@Joachim\_P](https://discourse.vtk.org/u/Joachim_P)
#### Post date: [November 25, 2020, 10:31pm UTC](https://discourse.vtk.org/t/clipping-by-scalar-from-celldata-vtkclipdataset-python/4724/2 "2020-11-25T22:31:42Z")

</div>

Jason,  
Could you elaborate on what result you are expecting here? By clipping do you mean extracting from the mesh a submesh that would contain all the cells of a given cell value?  
J.

---

<div class="post-metadata">

### Author: ![Jason1](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/b19c9b/32.png) [@Jason1](https://discourse.vtk.org/u/Jason1)
#### Post date: [November 30, 2020, 10:07am UTC](https://discourse.vtk.org/t/clipping-by-scalar-from-celldata-vtkclipdataset-python/4724/3 "2020-11-30T10:07:13Z")

</div>

Yes, I want a submesh separated from the rest by a certain tag value that is stored in the cells.  
But I already found a solution. I am using vtk.Treshold( ) with an upper bound for the tag values. This works fine for my case.
