This code works normally.
try: with hou.undos.group("my code"): hou.node('/obj/geo1').createNode('box') hou.node('/obj/geo1').createNode('box') raise hou.Error() except: hou.undos.performUndo()
However, if an error occurs before modifying the scene, the current undo group is not recorded in the undo history. The undo executed in the except block will cancel the previous operation.
try: with hou.undos.group("my code"): raise hou.Error() # raise exception before modifying scene , no undo is added to undo history. hou.node('/obj/geo1').createNode('box') hou.node('/obj/geo1').createNode('box') except: hou.undos.performUndo() # undo operation before my code
How to solve this problem?
Thanks!
