There are times in scripting for ParaView when it is useful to delete data objects or filters from the Pipeline Browser.
Most often, this occurs when you want to use a given ParaView session to produce multiple outputs (many slices, contours, variables, etc), instead of having to re-load your original data for each output.
Deleting from the Pipeline Browser can offer large savings in computational expense for long batch processes.
For the purposes of this article, we will be using Paraview 5.4.1.
For help running ParaView scripts, please see the batch-execution instructions.
Deleting objects from the Pipeline Browser manually is a simple process.
Simply highlight the object you wish to select in the browser, and press the “Delete” button.
Removing a data or filter object programatically is just as simple.
First make sure the
paraview.simple module has been imported:
Then, ensure you have a variable handle to your data object.
case = paraview.simple.OpenFOAMReader(FileName='/path/to/run.foam') data_display = paraview.simple.Show(case, render_view)
Then, simply delete the data object. The display object will be taken care of
automatically. It’s also best practice to clean up the variable afterward with
paraview.simple.Delete(case) del case