# Applying a Paraview Filter Directly from Script in Custom Application

**URL:** https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278
**Category:** Development
**Created:** [March 27, 2024, 2:38pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278 "2024-03-27T14:38:45Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![MulberryClassic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@MulberryClassic](https://discourse.paraview.org/u/MulberryClassic)
#### Post date: [March 27, 2024, 2:38pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/1 "2024-03-27T14:38:45Z")

</div>

Hello Experts,  
I want to apply the Extract Subset filter to a loaded volume data directly from the custom application script. The examples I have seen use GUI implementations. I want to know how can I just apply the filter without any GUI.  
Thank you

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 27, 2024, 2:48pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/2 "2024-03-27T14:48:30Z")

</div>

> [@MulberryClassic](#):
>
> the custom application script.

What is the custom application script ?

---

<div class="post-metadata">

### Author: ![MulberryClassic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@MulberryClassic](https://discourse.paraview.org/u/MulberryClassic)
#### Post date: [March 27, 2024, 3:18pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/3 "2024-03-27T15:18:32Z")

</div>

The mainWindow.cxx (similar to the ones in the example applications). I load in data by a reader, create data representation and render it.

```auto
// read data
pqPipelineSource* pipelineSource = pqLoadDataReaction::loadData(files, "sources", "PVDReader");
pipelineSource->updatePipeline();

// get the object builder
pqObjectBuilder *builder = pqApplicationCore::instance()->getObjectBuilder();
// create data representation and add it to render view
pqDataRepresentation *drep = builder->createDataRepresentation(pipelineSource->getOutputPort(0), view);
auto dProxy = drep->getProxy();
vtkSMPropertyHelper(dProxy, "Representation").Set("Volume");
// use color and opacity from original data
vtkSMPropertyHelper(dProxy, "UseSeparateColorMap").Set(1);
vtkSMColorMapEditorHelper::SetScalarColoring(dProxy, "MetaImage", vtkDataObject::POINT);
vtkSMColorMapEditorHelper::RescaleTransferFunctionToDataRange(dProxy, false, false);

dProxy->UpdateVTKObjects();
drep->setVisible(true);

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 27, 2024, 3:26pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/4 "2024-03-27T15:26:09Z")

</div>

> [@MulberryClassic](#):
>
> I want to know how can I just apply the filter without any GUI.

`pqObjectBuilder::createFilter` [ParaView: pqObjectBuilder Class Reference](https://kitware.github.io/paraview-docs/latest/cxx/classpqObjectBuilder.html#ad176272aa6ec9422c284cd0ed89c15ee)

---

<div class="post-metadata">

### Author: ![MulberryClassic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@MulberryClassic](https://discourse.paraview.org/u/MulberryClassic)
#### Post date: [March 27, 2024, 3:29pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/5 "2024-03-27T15:29:33Z")

</div>

Yes, I did try this with group = “filters” and name = “ExtractSubset”, but I couldn’t figure out how do I set the parameters for the filters, such as the VOI

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 27, 2024, 3:30pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/6 "2024-03-27T15:30:19Z")

</div>

use `vtkSMPropertyHelper` [ParaView: vtkSMPropertyHelper Class Reference](https://kitware.github.io/paraview-docs/latest/cxx/classvtkSMPropertyHelper.html)

---

<div class="post-metadata">

### Author: ![MulberryClassic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@MulberryClassic](https://discourse.paraview.org/u/MulberryClassic)
#### Post date: [March 27, 2024, 3:32pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/7 "2024-03-27T15:32:00Z")

</div>

Ok, thanks will do so. Also the parameters I passed seem incorrect.  
`No proxy that matches: group=filters and proxy=ExtractSubset were found.`  
Is there any reference where I can find the accepted values?  
Thanks alot

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 27, 2024, 3:35pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/8 "2024-03-27T15:35:12Z")

</div>

> [@MulberryClassic](#):
>
> Is there any reference where I can find the accepted values?

In the XML files of ParaView:  
[https://gitlab.kitware.com/paraview/paraview/-/blob/master/VTKExtensions/FiltersGeneral/Resources/general\_filters.xml?ref\_type=heads#L1090](https://gitlab.kitware.com/paraview/paraview/-/blob/master/VTKExtensions/FiltersGeneral/Resources/general_filters.xml?ref_type=heads#L1090)

As you can see `Extract Subset` is the label, you want to use the name `ExtractGrid`.

---

<div class="post-metadata">

### Author: ![MulberryClassic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/a87d85/32.png) [@MulberryClassic](https://discourse.paraview.org/u/MulberryClassic)
#### Post date: [March 27, 2024, 3:41pm UTC](https://discourse.paraview.org/t/applying-a-paraview-filter-directly-from-script-in-custom-application/14278/9 "2024-03-27T15:41:05Z")

</div>

Thanks alot!

```auto
pipelineSource = builder->createFilter("filters", "ExtractGrid", pipelineSource);
int voi[6] = {0, 128, 0, 128, 0, 128};
vtkSMPropertyHelper(pipelineSource->getProxy(), "VOI").Set(voi, 6);
pipelineSource->getProxy()->UpdateVTKObjects();

```
