How can i play and stop stage with extension of kit

I want to develop a simulation data software based on kit. At present, what I want to achieve is to complete scene play, data collection and scene stop in the extension. How can I realize automatic batch collection of simulation data?

you could register a timeline event listener and get play/stop events, then query the data you need during that time:

    def on_timeline_event(e):
        if e.type == int(omni.timeline.TimelineEventType.PLAY):

        if e.type == int(omni.timeline.TimelineEventType.PAUSE):

    timeline_events = omni.timeline.get_timeline_interface().get_timeline_event_stream()
    state.timeline_event_sub = timeline_events.create_subscription_to_pop(on_timeline_event)

You can create a subscription to Kit update:

def _on_update(self, e):

self._update_sub =, name="my update")

Is this what you are looking for?

Thank you very much for answering me. According to your idea, I have completed automatic playing、stopping the scene and saving RGB images through custom extension. But I have encountered a new problem. How can I save the mask of objects in the scene like RGB images?Some codes are as follows:
from omni.syntheticdata import helpers, sensors
import omni.syntheticdata._syntheticdata as sd
sd_interface = sd.acquire_syntheticdata_interface()
data = sd_interface.get_sensor_host_uint32_texture_array(sensor)

I want to get the mask of object of scene, but i failed.

@xiaohualiao0319 I would suggest you take a look at omniverse replicator

There are many tutorials on randomization and saving synthetic data.