If you have a dataset that moves over time and you would like a Clip filter to follow the center of that dataset, you can do the following.
- Load or create the data set. Assume the name of the data source in the Pipeline Browser is “DataSource1” (if you loaded a file, e.g. “can.ex2”, the data set will be named “can.ex2” in the Pipeline Browser).
- Add a Clip filter and set the Clip Type to “Plane”. Assume this filter is named “Clip1” in the Pipeline Browser.
- Open up the Animation View under the View menu.
- Next to the blue plus sign, change the combo box to the “Python” option and then click the plus sign.
- To the right of the “Python” animation track, double click the long rectangle under the time line. In the dialog that pops up, enter the following code:
from paraview.simple import FindSource def start_cue(self): pass def tick(self): s = FindSource('DataSource1') bounds = s.GetDataInformation().GetBounds() center = [0.5*(bounds+bounds), 0.5*(bounds+bounds), 0.5*(bounds+bounds)] c = FindSource('Clip1') c.ClipType.Origin = center def end_cue(self): pass
This will set the origin of the Clip filter’s plane to the center of the bounding box of the data source. The
tick function is called each time the timestep is updated, so the Clip filter origin will be updated to the center of the dataset each time the time step changes.
To have a Clip filter track a single cell in data set over time, first select the cell using ParaView’s selection tools. Then, apply an Extract Selection filter, and replace ‘DataSource1’ with the name of the Extract Selection filter in the Pipeline Browser in the Python script above.