Applying a Paraview Filter Directly from Script in Custom Application

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

What is the custom application script ?

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

// read data
pqPipelineSource* pipelineSource = pqLoadDataReaction::loadData(files, "sources", "PVDReader");

// 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);


pqObjectBuilder::createFilter ParaView: pqObjectBuilder Class Reference

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

use vtkSMPropertyHelper ParaView: vtkSMPropertyHelper Class Reference

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

In the XML files of ParaView:

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

Thanks alot!

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