# Filter that takes a geometry and a selection as input

**URL:** https://discourse.paraview.org/t/filter-that-takes-a-geometry-and-a-selection-as-input/15245
**Category:** Development
**Created:** [August 17, 2024, 8:08am UTC](https://discourse.paraview.org/t/filter-that-takes-a-geometry-and-a-selection-as-input/15245 "2024-08-17T08:08:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [August 17, 2024, 8:08am UTC](https://discourse.paraview.org/t/filter-that-takes-a-geometry-and-a-selection-as-input/15245/1 "2024-08-17T08:08:11Z")

</div>

Once I learned that in the SM XML file for a filter that takes some data plus a selection input, this would describe the selection input:

```auto
      <InputProperty command="SetSelectionConnection"
                     name="Selection">
        <ProxyGroupDomain name="groups">
          <Group name="sources"/>
          <Group name="filters"/>
        </ProxyGroupDomain>
        <DataTypeDomain name="input_type">
          <DataType value="vtkSelection"/>
        </DataTypeDomain>
        <Documentation>
          The input that provides the selection object.
        </Documentation>
        <Hints>
          <SelectionInput/>
        </Hints>
      </InputProperty>

```

In the C++ code I can access this input then as a `vtkSelection` object and deal with it accordingly. I did all this, and in order to make sure I have nothing forgotten, I compared with the existing code of the `Extract Selection` filter.

However there is now one thing different: If I select some geometry in the pipeline, then select some cells in that geometry with any of the selection tools, then add the `Extract Selection` filter to my pipeline, I will see immediately my selection also in the “SelectionInput” widget of the properties panel.

If I do exactly the same thing with my own plugin, the “SelectionInput” widget is initially empty and I will see my previously defined selections only after pressing the “Copy Active Selection” button.

My question is: What is the trick to do this initial “Copy Active Selection” like the “Extract Selection” filter does it? Comparing as much code as I want, I do not find the difference!

---

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [August 19, 2024, 4:17pm UTC](https://discourse.paraview.org/t/filter-that-takes-a-geometry-and-a-selection-as-input/15245/2 "2024-08-19T16:17:19Z")

</div>

After days and days of struggling with the debugger deep inside the ParaView code I finally found the solution: `vtkSMExtractSelectionProxyInitializationHelper`.

In other words: You need to implement a “helper class” (that can simply be a renamed copy of the above) that does the job explicitly.

(Several years ago I must have known it, but right now I had no such class left inside my code - and the “Extract Selection” filter is not a simple beast: All the required parts are spread out somehow in the source code tree…)
