# Query Selection not captured in Python state file

**URL:** https://discourse.paraview.org/t/query-selection-not-captured-in-python-state-file/6182
**Category:** Development
**Tags:** python
**Created:** [January 7, 2021, 11:45pm UTC](https://discourse.paraview.org/t/query-selection-not-captured-in-python-state-file/6182 "2021-01-07T23:45:16Z")
**Posts on this page:** 2
**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: [January 7, 2021, 11:45pm UTC](https://discourse.paraview.org/t/query-selection-not-captured-in-python-state-file/6182/1 "2021-01-07T23:45:16Z")

</div>

Tested with 5.9.0 RC3 Windows MPI version.

To reproduce, run the following as a macro or load as state file (update the save filename).  
Look at the resulting file.

```python
from paraview.simple import *

sphere = Sphere()
QuerySelect(QueryString='(id == 1)', FieldType='CELL', InsideOut=0)
extractSelection = ExtractSelection(Input=sphere)
Show(extractSelection)
state = paraview.smstate.get_state()
with open('./test_state.py', 'w') as f:
    f.writelines(state)

```

Also, note that I’m not using `SaveState` because it writes a xml-style file regardless of the file extension used. That also needs to be fixed.

---

<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: [February 12, 2021, 10:59pm UTC](https://discourse.paraview.org/t/query-selection-not-captured-in-python-state-file/6182/2 "2021-02-12T22:59:33Z")

</div>

You are right, the selection is not recorded in the Python state file. A related bug has been reported here: [https://gitlab.kitware.com/paraview/paraview/-/issues/20306](https://gitlab.kitware.com/paraview/paraview/-/issues/20306)
