Frequently Used Snippets

A collection of python utility snippets that can be used in the script editor or pure python applications

Simple Async Task

 1import asyncio
 2import omni
 3
 4# Async task that pauses simulation once the incoming task is complete
 5async def pause_sim(task):
 6    done, pending = await asyncio.wait({task})
 7    if task in done:
 8        print("Waited until next frame, pausing")
 9        omni.timeline.get_timeline_interface().pause()
10
11# Start simulation, then wait a frame and run the pause_sim task
12omni.timeline.get_timeline_interface().play()
13task = asyncio.ensure_future(omni.kit.app.get_app().next_update_async())
14asyncio.ensure_future(pause_sim(task))