# Extract Block filter for multi-block data set

**URL:** https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026
**Category:** ParaView Support
**Created:** [August 4, 2020, 1:31pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026 "2020-08-04T13:31:39Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![kirit\_101](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/b19c9b/32.png) [@kirit\_101](https://discourse.paraview.org/u/kirit_101)
#### Post date: [August 4, 2020, 1:31pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/1 "2020-08-04T13:31:39Z")

</div>

Hello:  
I have a multi-block data set, where I am using Extract Block filter to seperate some data . I created a python state file, python script looks like this :

```
# create a new 'Extract Block'
extractBlock1 = ExtractBlock(registrationName='ExtractBlock1', Input=post000041_400003e00h5)
extractBlock1.BlockIndices = [3]
extractBlock1.MaintainStructure = 1

# create a new 'Extract Block'
extractBlock2 = ExtractBlock(registrationName='ExtractBlock2', Input=post000041_400003e00h5)
extractBlock2.BlockIndices = [4]
extractBlock2.MaintainStructure = 1

```

When I run this script, In GUI, I have to manually choose the dataset again and apply. Is there any elegant way to apply the filter in python script ?

![paraview_questions](https://discourse.paraview.org/uploads/default/original/2X/6/6fc7287afc114eafca53ffcfca8ef2d25646cf91.png)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 4, 2020, 1:49pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/2 "2020-08-04T13:49:29Z")

</div>

```
extractBlock.UpdatePipeline()
extractBlock2.UpdatePipeline()
```

---

<div class="post-metadata">

### Author: ![kirit\_101](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/b19c9b/32.png) [@kirit\_101](https://discourse.paraview.org/u/kirit_101)
#### Post date: [August 4, 2020, 3:50pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/3 "2020-08-04T15:50:44Z")

</div>

Thanks Mathieu.  
Now I have update my python script. Now it looks like this :

# create a new ‘Extract Block’

extractBlock1 = ExtractBlock(registrationName=‘ExtractBlock1’, Input=post000041\_400003e00h5)  
extractBlock1.BlockIndices = [3]  
extractBlock1.MaintainStructure = 1  
extractBlock1.UpdatePipeline()

# create a new ‘Extract Block’

extractBlock2 = ExtractBlock(registrationName=‘ExtractBlock2’, Input=post000041\_400003e00h5)  
extractBlock2.BlockIndices = [4]  
extractBlock2.MaintainStructure = 1  
extractBlock2.UpdatePipeline()

Still I don’t see they are updating automatically . I have tested this in version 5.8.1 RC1 and 5.8.1 RC2.  
Is this related to version ?

---

<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 4, 2020, 7:34pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/4 "2020-08-04T19:34:05Z")

</div>

I suspect you want to

```python
Show(extractBlock1)
Show(extractBlock2)

```

to mimic the effect of the “Apply” button.

---

<div class="post-metadata">

### Author: ![kirit\_101](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/b19c9b/32.png) [@kirit\_101](https://discourse.paraview.org/u/kirit_101)
#### Post date: [August 4, 2020, 9:47pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/5 "2020-08-04T21:47:57Z")

</div>

Thanks Cory.  
Show operation is bringing the eye icon. But my issue is when I run this script ( with UpdatePipeline and Show method) my block **is not automatically selected and applied**. As you can see in the image below. This was taken after I run the script, In the block indices, none is selected.

![paraview_questions](https://discourse.paraview.org/uploads/default/original/2X/6/6fc7287afc114eafca53ffcfca8ef2d25646cf91.png)

I have also tried giving list names instead of numbers. No luck.

# create a new ‘Extract Block’

extractBlock1 = ExtractBlock(registrationName=‘ExtractBlock1’, Input=post000041\_400003e00h5)  
extractBlock1.BlockIndices = [‘Surface’]  
extractBlock1.MaintainStructure = 1  
extractBlock1.UpdatePipeline()  
Show(extractBlock1)

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [August 4, 2020, 10:31pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/6 "2020-08-04T22:31:51Z")

</div>

I think this is indeed a bug. Just calling `extractBlock1.BlockIndices = [<number>]` should have reflected correctly in the UI.

Mind reporting an issue on the [issue tracker](https://gitlab.kitware.com/paraview/paraview/-/issues) so we can track it down? Thanks.

---

<div class="post-metadata">

### Author: ![kirit\_101](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/b19c9b/32.png) [@kirit\_101](https://discourse.paraview.org/u/kirit_101)
#### Post date: [August 5, 2020, 8:05pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/7 "2020-08-05T20:05:06Z")

</div>

Thanks @utkarsh.ayachit. I have report an issue

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [April 6, 2021, 8:27am UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/8 "2021-04-06T08:27:52Z")

</div>

Could you test with a recent nightly @kirit_101 ?

---

<div class="post-metadata">

### Author: ![kirit\_101](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/b19c9b/32.png) [@kirit\_101](https://discourse.paraview.org/u/kirit_101)
#### Post date: [April 6, 2021, 3:49pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/9 "2021-04-06T15:49:04Z")

</div>

Thanks, @mwestphal. I have tested this on the recent nightly version (ParaView-5.9.0-862-g8ea174d9d4) and this works fine. I have also tested in Paraview 5.9.0 RC1, which works fine too.

Just to keep this documented for future readers. Python codes have changed from Version 5.9.0 RC1 to the recent nightly version.

# For Paraview 5.9.0 RC1:

extractBlock1 = ExtractBlock(registrationName=‘ExtractBlock1’, Input=post000004\_148100e03h5)  
extractBlock1.BlockIndices = [3]

# For recent nightly version:

extractBlock1 = ExtractBlock(registrationName=‘ExtractBlock1’, Input=post000004\_148100e03h5)  
extractBlock1.Selectors = [’/Root/Block0/Block1’]

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [April 8, 2021, 1:39pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/10 "2021-04-08T13:39:06Z")

</div>

FYI, the changes in master are a work-in-progress. As discussed [here](https://discourse.paraview.org/t/data-hierarchy-how-to-name-blocks/6546), I am currently making changes to setup the node names to match a sanitized version of the “label” provided, if any. So, in your case, to select Surface, for example, setting selectors to `['//Surface']` will do the trick.

---

<div class="post-metadata">

### Author: ![Mothertrucker19](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mothertrucker19/32/11307_2.png) [@Mothertrucker19](https://discourse.paraview.org/u/Mothertrucker19)
#### Post date: [March 30, 2023, 4:06pm UTC](https://discourse.paraview.org/t/extract-block-filter-for-multi-block-data-set/5026/11 "2023-03-30T16:06:04Z")

</div>

Hi  
Is it possible to select using selectors with parts of a string matching? For example there are multiple blocks containing surface.  
Or retrive the name of the blocks?
