# ParaView 5.10.0 RC1 Extract Block Selectors

**URL:** https://discourse.paraview.org/t/paraview-5-10-0-rc1-extract-block-selectors/8194
**Category:** Development
**Tags:** python
**Created:** [October 14, 2021, 9:12pm UTC](https://discourse.paraview.org/t/paraview-5-10-0-rc1-extract-block-selectors/8194 "2021-10-14T21:12:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![theodorebaltis](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/t/e480ec/32.png) [@theodorebaltis](https://discourse.paraview.org/u/theodorebaltis)
#### Post date: [October 14, 2021, 9:12pm UTC](https://discourse.paraview.org/t/paraview-5-10-0-rc1-extract-block-selectors/8194/1 "2021-10-14T21:12:12Z")

</div>

I tried the new `ExtractBlock` filter and it functions just as expected (no more changing parts between timestates!) but I have a few comments/concerns.

1. From what I see the only way to directly set the xpath-style selectors is through Python.  
For some reason I was expecting to have some kind of text input in the ExtractBlock properties. Was this ever under consideration? I think it would add much value for non-power users.

2. It appears that blocks starting with a number need an underscore prefix. Can this requirement be removed? It’s going to be one of those things that I end up telling every user at least once and they’re all going to say “Ahhhh. Why? That’s stupid” 😜

```python
['/Root/Solid/_1_soil_tube', '/Root/Solid/_3_HE']

```

![temp_extract_block](https://discourse.paraview.org/uploads/default/original/2X/4/488839ec4e023409f05646c6f3d93a9296d32a93.png)

1. What is up with the drop-down menu below the Blocks structure? Under what circumstances can I except this menu to contain multiple options and how does it affect the selection process?

2. I can select all the Solid blocks in the above image using `['/Root/Solid/*']` but I cannot select parts 6 and 7 using `['/Root/Solid/*block']`  
And using `['/Root/*/_2_soil']` selects only the block under Solid.  

3. Is there a way to use the shown top-level block name instead of (or ideally in addition to) `'Root'`? I expect users are going to try `['/vtkMultiBlockDataSet/Solid']`.

---

<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: [October 15, 2021, 1:29pm UTC](https://discourse.paraview.org/t/paraview-5-10-0-rc1-extract-block-selectors/8194/2 "2021-10-15T13:29:40Z")

</div>

> [@theodorebaltis](#):
>
> From what I see the only way to directly set the xpath-style selectors is through Python.  
> For some reason I was expecting to have some kind of text input in the ExtractBlock properties. Was this ever under consideration? I think it would add much value for non-power users.

Try hitting the “gear” to enter advanced view for the panel. You’ll see the **Selectors** tab.

![image](https://discourse.paraview.org/uploads/default/original/2X/b/b02674229e9cc322f6fffed84f9e494a8cc7f2cc.png)

> It appears that blocks starting with a number need an underscore prefix.

Internal representation uses XML. That requires the block names are valid XML node names. That requires changes to such block names when they are not valid XML node names. Multiple options:

- remove the number prefixes from the blocks.
- use `@label`, ex. `//*[@label="1_soil_tube"]`

> What is up with the drop-down menu below the Blocks structure?

For `vtkPartitionedDataSetCollection`, we support a separate assembly. If you open `can.ex2` from ParaViewData for example:

![image](https://discourse.paraview.org/uploads/default/original/2X/e/ee40ed7506253c0a400d4c5f28f5426dc8bc7e9f.png)  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/e/e4abf95cf3d375998ba8ad18f3b078b74b3e4d79.png)

> Using simple wildcards (I suppose regex is too complicated) would add a ton of value, at my company at least.

Here’s info about supported [XPath](https://pugixml.org/docs/manual.html#xpath).

> Is there a way to use the shown top-level block name instead of (or ideally in addition to) `'Root'` ?

Should be fixable. Please report an issue.

---

<div class="post-metadata">

### Author: ![theodorebaltis](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/t/e480ec/32.png) [@theodorebaltis](https://discourse.paraview.org/u/theodorebaltis)
#### Post date: [October 15, 2021, 6:11pm UTC](https://discourse.paraview.org/t/paraview-5-10-0-rc1-extract-block-selectors/8194/3 "2021-10-15T18:11:16Z")

</div>

> [@utkarsh.ayachit](#):
>
> Try hitting the “gear” to enter advanced view for the panel. You’ll see the **Selectors** tab.

Ah, I don’t how I missed that. I should know better.

> [@utkarsh.ayachit](#):
>
> Here’s info about supported [XPath](https://pugixml.org/docs/manual.html#xpath).

Thanks, my understanding of XPath was a little (maybe very) off.

So I see that I have to use the expression `//*[contains(@label,'2_soil')]` to select both blocks that start with **2\_soil** because of the **[1]** duplicate identifier that is automatically added.  
Is there another XML attribute that holds the literal block/grid name as defined in the .xmf file if the data source is the XDMF format?

Relevant portion of my .xmf file:

```xml
      <Grid GridType="Collection" CollectionType="Spatial" Name="SPH">
        <Grid GridType="Uniform" Name="2_soil">
          <Attribute Name="PartID" Center="Grid" AttributeType="Scalar">
            <DataItem Format="XML" Dimensions="1" DataType="Int">2</DataItem>

```

And regardless of the answer to that, I’m thinking I might want to build a custom filter that simplifies the selector syntax for the user. Would basically be a wrapper around this new ExtractBlocks filter that translates my own selector language to the required XPath one.

Would this be possible? Can I access the internal XML representations and ExtractBlock operations on the VTK side? I know I could just iterate through the MBDS itself and look at each block name but I’d love to take advantage of the XPath capabilities.

---

<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: [October 16, 2021, 12:38pm UTC](https://discourse.paraview.org/t/paraview-5-10-0-rc1-extract-block-selectors/8194/4 "2021-10-16T12:38:15Z")

</div>

> [@theodorebaltis](#):
>
> Is there another XML attribute that holds the literal block/grid name as defined in the .xmf file if the data source is the XDMF format?

In theory, yes. But would need some work. Ideally, the reader starts producing `vtkPartitionedDataSetCollection` instead of `vtkMultiBlockDataSet`. Then it can attach arbitrary assembly to the dataset. That assembly should be able to represent the XMF structure.

> Can I access the internal XML representations and ExtractBlock operations on the VTK side?

See `vtkExtractBlockUsingDataAssembly`.
