omni.kit.usd_undoΒΆ

Utitlity to implement undo for USD layer.

UsdLayerUndo class is the utility to help you to implement USD undo. It reserves the state of a path, which could be a prim path or a property path. And when you call UsdLayerUndo.undo(), those paths will be restored to their reserved state.

Example:

import omni.kit.usd_undo

usd_undo = omni.kit.usd_undo.UsdLayerUndo(stage.GetEditTarget().GetLayer())

usd_undo.reserve("/root/prim")

'''Do anything to prim /root/prim here, including creating/deleting prim,
modifying/creating/deleting meta data or fields, modifying/creating/deleting
any attributes, modifying/creating/deleting any descendants, etc.'''

usd_undo.reserve("root/prim2.prop")

'''Do anything to property root/prim2.prop here, including creating, deleting,
modifying, etc.'''

usd_undo.reserve("root/prim2", Usd.Tokens.apiSchemas)

'''Do anything to apiSchemas field of prim root/prim2 here.'''

# Call UsdLayerUndo.undo() to revert all changes of those paths.
usd_undo.undo()