Slicing in response to time change

This script shows how you can use Python callbacks to change a slice plane as a function of the current time state. We create a plot, slice it along its X-axis, and then install a Python callback function that modifies the slice plane as a function of the new time state.

# Set up a plot
AddPlot("Pseudocolor", "pressure")

# Add a slice operator that keeps the slice in 3D and slices along the
# X-axis as a percentage of the extents.
s = SliceAttributes()
s.project2d = 0
s.originType = s.Percent
s.axisType = s.XAxis

# This callback function computes the percent through the time series for the
# current time state and uses that percentage as a percentage for the slice
def onSetTimeSliderState(timeState, userData):
    nts = TimeSliderGetNStates()
    percent = 0.
    if nts > 1:
        percent = float(timeState) / float(TimeSliderGetNStates()-1)
    s.originPercent = percent * 100.

RegisterCallback("SetTimeSliderStateRPC", onSetTimeSliderState, s)