API (python)
Module Summary:
Commands for Omniverse Kit. |
|
Module Details::
No module docstring provided
Commands for Omniverse Kit.
omni.kit.commands
module is used to register and execute Commands. It is built on top of omni.kit.undo
module to enable undo/redo operations with Commands.
Command is any class with do()
method and optionally undo()
method. If Command has undo()
method it is put on the undo stack when executed.
It must be inherited from Command
class for type checking.
Example of creating your command, registering it, passing arguments and undoing.
class MyOrange(omni.kit.commands.Command):
def __init__(self, bar: list):
self._bar = bar
def do(self):
self._bar.append('orange')
def undo(self):
del self._bar[-1]
>>> import omni.kit.commands
>>> omni.kit.commands.register(MyOrangeCommand)
>>> my_list = []
>>> omni.kit.commands.execute("MyOrange", bar=my_list)
>>> my_list
['orange']
>>> import omni.kit.undo
>>> omni.kit.undo.undo()
>>> my_list
[]
>>> omni.kit.undo.redo()
>>> my_list
['orange']
No module docstring provided