# Selection for ExtractSelection not saved in state

**URL:** https://discourse.paraview.org/t/selection-for-extractselection-not-saved-in-state/16113
**Category:** ParaView Support
**Tags:** python
**Created:** [February 5, 2025, 6:11pm UTC](https://discourse.paraview.org/t/selection-for-extractselection-not-saved-in-state/16113 "2025-02-05T18:11:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alwaysonemorebug](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@alwaysonemorebug](https://discourse.paraview.org/u/alwaysonemorebug)
#### Post date: [February 5, 2025, 6:11pm UTC](https://discourse.paraview.org/t/selection-for-extractselection-not-saved-in-state/16113/1 "2025-02-05T18:11:40Z")

</div>

The topic is a [known bug](https://gitlab.kitware.com/paraview/paraview/-/issues/20306) and was discussed in the past, but I cannot get the [proposed workaround](https://gitlab.kitware.com/paraview/paraview/-/issues/20306) to work.

Situation:  
My pipeline is created by a Python script. To work on a subset of the data, I use `QuerySelect` followed by `ExtractSelection`, e. g.:

```auto
nmdSel = QuerySelect(QueryString='(nmd == 5)', FieldType='CELL', InsideOut=0)
extractSelectionNMD = ExtractSelection(registrationName='extractSelectionNMD', Input=transform1, Selection=nmdSel)

```

**When I use the `SaveState` command, the `QuerySelect` part is not saved. When I load the saved state in a new session, the pipeline is broken because of the missing selection in `ExtractSelection`.**

A potential solution is not working:  
During the search for a solution, I found a [post from 2020 where the use of `SelectionQuerySource` is proposed as a workaround](https://gitlab.kitware.com/paraview/paraview/-/issues/20306). The post says to remove  
`QuerySelect(QueryString='id == 1', FieldType='CELL', InsideOut=0)`  
and to add

```auto
sqs = SelectionQuerySource( ProcessID=-1, QueryString='id==1', HierarchicalIndex=-1, FieldType='POINT', HierarchicalLevel=-1)
extractSelection1.Selection = sqs

```

Problem:  
When I try to execute `SelectionQuerySource` with `FieldType='POINT'` (or with `FieldType='CELL'`), I’m getting an error message saying that `SelectionQuerySource` has no attribute `FieldType`. In the [documentation of `SelectionQuerySource`](https://www.paraview.org/paraview-docs/latest/python/paraview.simple.SelectionQuerySource.html), I see “field type” in the text and an attribute called `FieldTypeOption`, but no attribute `FieldType`. I tried some variations of the SelectionQuerySource command, but my knowledge of ParaView (and its data structures) is not sufficient to get it to work.

**Is there a solution or workaround that allows to save a selection used for `ExtractSelection` in a saved state?**  
**Why is `FieldType='CELL'` not working anymore for `SelectionQuerySource`?**

I’m using ParaView 5.11.2 on Windows 11.

Additional information found during the search for a solution:

- Another example (from 2013) where [`FieldType='POINT'` is used with `SelectionQuerySource`](https://www.paraview.org/pipermail/paraview/2013-June/028566.html)
- A [Python code snippet allowing to save the state to a .py file](https://discourse.paraview.org/t/query-selection-not-captured-in-python-state-file/6182). (The `SaveState` command “only” allows to save to a .pvsm file.) Doesn’t help, the selection is also missing in the .py file.
- A [post](https://discourse.paraview.org/t/using-find-data-aka-extract-selection-with-python-scripting/562) and an [issue](https://gitlab.kitware.com/paraview/paraview/-/issues/16836) of the possibly related topic of Find Data selections being missed by the trace recorder

---

<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: [February 5, 2025, 7:06pm UTC](https://discourse.paraview.org/t/selection-for-extractselection-not-saved-in-state/16113/2 "2025-02-05T19:06:04Z")

</div>

Did you try the `SelectPoints` method as mentioned [here](https://discourse.paraview.org/t/using-find-data-aka-extract-selection-with-python-scripting/562/6)?

---

<div class="post-metadata">

### Author: ![alwaysonemorebug](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/65b543/32.png) [@alwaysonemorebug](https://discourse.paraview.org/u/alwaysonemorebug)
#### Post date: [February 5, 2025, 10:53pm UTC](https://discourse.paraview.org/t/selection-for-extractselection-not-saved-in-state/16113/3 "2025-02-05T22:53:51Z")

</div>

Thanks for the suggestion.  
Yes, I tried.  
At a first attempt, both `SelectPoints()` and `SelectCells()` caused ParaView to crash at the line `selection=SelectPoints()`. Not even an error message, the ParaView window just disappears. This seems unusual, I’ve not seen that before. I could try to narrow it down by simplifying my pipeline and see if the switch from `QuerySelect(..., FieldType='CELL', ...)` to `SelectCells` makes a difference.  
Do you have any other example showing the use of `SelectPoints` and `SelectCells`? I struggle to understand the [code posted by Jean M. Favre on Oct. 1, 2018](https://discourse.paraview.org/t/using-find-data-aka-extract-selection-with-python-scripting/562/5). According to the [documentation of `SelectPoints`](https://www.paraview.org/paraview-docs/latest/python/paraview.simple.html), the only arguments of `SelectPoints()` are `query` and `proxy`. But the post suggests to define `FieldType` and `QueryString` after `SelectPoints`. `selection=SelectPoint()` defines that points shall be selected. I don’t get the point (😀) of `selection.FieldType='POINT'` two lines later in that post.
