# ExtractCellsByRegion() via pvpython

**URL:** https://discourse.paraview.org/t/extractcellsbyregion-via-pvpython/4951
**Category:** ParaView Support
**Tags:** python
**Created:** [July 24, 2020, 3:14pm UTC](https://discourse.paraview.org/t/extractcellsbyregion-via-pvpython/4951 "2020-07-24T15:14:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jclai](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jclai/32/4482_2.png) [@jclai](https://discourse.paraview.org/u/jclai)
#### Post date: [July 24, 2020, 3:14pm UTC](https://discourse.paraview.org/t/extractcellsbyregion-via-pvpython/4951/1 "2020-07-24T15:14:48Z")

</div>

Hello,

I am searching for a way to select a part of my data. I have a dataset that consists of a small geometry (has volume) enclosed by a cylindrical boundary surface (hollow aside from the small geometry inside). I want to select only the internal geometry.

In the ParaView GUI, using Select Cells On, I manually select the boundary cells, rotate the render view, and repeatedly add to the current selection until all boundary cells are selected. Then I click Find Data \> Invert selection so that only the small geometry/volume inside is selected.

What is the best way to program this?

---

<div class="post-metadata">

### Author: ![jclai](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jclai/32/4482_2.png) [@jclai](https://discourse.paraview.org/u/jclai)
#### Post date: [July 24, 2020, 3:59pm UTC](https://discourse.paraview.org/t/extractcellsbyregion-via-pvpython/4951/2 "2020-07-24T15:59:15Z")

</div>

I discovered that the ExtractCellsByRegion() filter works perfectly if I extract using a box. I want to set the properties to the following:  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/c/c3165324220d2fa8d5939a7edc0f5921c1683c64.png)

However, I still do not know how to specify those parameters when calling the function.

---

<div class="post-metadata">

### Author: ![jclai](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jclai/32/4482_2.png) [@jclai](https://discourse.paraview.org/u/jclai)
#### Post date: [July 24, 2020, 4:57pm UTC](https://discourse.paraview.org/t/extractcellsbyregion-via-pvpython/4951/3 "2020-07-24T16:57:26Z")

</div>

I tried to create a separate box object to use as a property when I call the function:

```
>>> reader = ExtractRegionSurface(reader)
>>> box = Box(XLength=0.006, YLength=0.025, ZLength=0.006)
>>> swimmer = ExtractCellsByRegion(Input=reader, IntersectWith=box)

```

I get this error. I know I am probably assigning the **IntersectWith** property incorrectly, but I do not know the correct syntax. What is the right way to do it?

```
( 72.795s) [paraview] vtkPVSessionCore.cxx:371 ERR| vtkPVSessionCore (0000020C1E1DD660): Object type: vtkExtractGeometry, could not find requested method: "SetImplicitFunction"
or the method was called with incorrect arguments.

while processing
Message 0 = Invoke
  Argument 0 = vtk_object_pointer {vtkExtractGeometry (0000020C22785000)}
  Argument 1 = string_value {SetImplicitFunction}
  Argument 2 = vtk_object_pointer {vtkCubeSource (0000020C213E5BE0)}

( 72.893s) [paraview] vtkPVSessionCore.cxx:372 ERR| vtkPVSessionCore (0000020C1E1DD660): Aborting execution for debugging purposes.
############ ABORT #############
( 72.905s) [paraview] vtkSIProxy.cxx:155 ERR| vtkSISourceProxy (0000020C22612E10): Error pushing property state: ImplicitFunction
global_id: 354
location: 1
[paraview_protobuf.ProxyState.property] {
  name: "ImplicitFunction"
  value {
    type: INPUT
    proxy_global_id: 342
    port_number: 0
  }
  user_data {
    key: "ProxyListDomain"
    variant {
      type: PROXY
      proxy_global_id: 365
      proxy_global_id: 366
      proxy_global_id: 367
    }
  }
}
```

---

<div class="post-metadata">

### Author: ![randomwangran](https://discourse.paraview.org/user_avatar/discourse.paraview.org/randomwangran/32/5929_2.png) [@randomwangran](https://discourse.paraview.org/u/randomwangran)
#### Post date: [July 26, 2020, 2:30am UTC](https://discourse.paraview.org/t/extractcellsbyregion-via-pvpython/4951/4 "2020-07-26T02:30:47Z")

</div>

Do you consider `clip` your data first? For example using type  
`Cylinder` to confine the data of your interest?

---

<div class="post-metadata">

### Author: ![jclai](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jclai/32/4482_2.png) [@jclai](https://discourse.paraview.org/u/jclai)
#### Post date: [July 27, 2020, 10:26pm UTC](https://discourse.paraview.org/t/extractcellsbyregion-via-pvpython/4951/5 "2020-07-27T22:26:38Z")

</div>

Thanks for your idea! I actually solved it by using the Select Cells by Region and used the box to do so. I figured out the syntax as well.
