# How to delete or update a preset from Python

**URL:** https://discourse.paraview.org/t/how-to-delete-or-update-a-preset-from-python/12548
**Category:** ParaView Support
**Tags:** python
**Created:** [July 20, 2023, 8:41am UTC](https://discourse.paraview.org/t/how-to-delete-or-update-a-preset-from-python/12548 "2023-07-20T08:41:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rojj](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rojj/32/1409_2.png) [@Rojj](https://discourse.paraview.org/u/Rojj)
#### Post date: [July 20, 2023, 8:41am UTC](https://discourse.paraview.org/t/how-to-delete-or-update-a-preset-from-python/12548/1 "2023-07-20T08:41:33Z")

</div>

Is it possible to update or delete a preset using Python? I could not find it in the [docs](https://kitware.github.io/paraview-docs/latest/python/paraview.simple.html)

My application uses some custom presets that are loaded with a script when ParaView starts.

```auto
for colormap in results["presets"]["xml"]:
    LoadLookupTable(os.path.join(results["presets"]["path"], f"{colormap}.xml"))

```

The problem arises when I update a preset for whatever reason. The new preset is loaded (I can see it in the list), but it is not applied.  
The reason seems to be that when ParaView quits it saves the presets in `.config/ParaView/ParaView-UserSettings.json`. Here I can see both versions, but maybe only the first one is actually used by `ApplyPreset(preset_name)`.

I thought of editing the `ParaView-UserSettings.json` directly and removing the old preset definition, but I have a mix of categorical and normal colormaps and it is not immediately obvious how to parse the content of `CustomPresets` in the file.

Of course there would be the nuclear option to delete the file before launching ParaView, but it would not be nice for the user 🙂

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [July 20, 2023, 2:47pm UTC](https://discourse.paraview.org/t/how-to-delete-or-update-a-preset-from-python/12548/2 "2023-07-20T14:47:03Z")

</div>

Well, indeed, there is no easy API for that (i.e., nothing in `simple.py`). But you can manage to do something with the `vtkSMTransferFunctionPresets` singleton, as done inside `LoadLookupTable`.

Something like this:;

```python
presets = servermanager.vtkSMTransferFunctionPresets.GetInstance()
for idx in range(presets.GetNumberOfPresets()):
  if presets.GetPresetName(idx) == "MyPreset":
    presets.RemovePreset(idx)
    break

```

You cannot delete default presets.

More about this object in C++ doc [here](https://kitware.github.io/paraview-docs/latest/cxx/classvtkSMTransferFunctionPresets.html)

---

<div class="post-metadata">

### Author: ![Rojj](https://discourse.paraview.org/user_avatar/discourse.paraview.org/rojj/32/1409_2.png) [@Rojj](https://discourse.paraview.org/u/Rojj)
#### Post date: [July 20, 2023, 4:11pm UTC](https://discourse.paraview.org/t/how-to-delete-or-update-a-preset-from-python/12548/3 "2023-07-20T16:11:10Z")

</div>

Thanks @nicolas.vuaille . It works perfectly.
