pymel.core.system.UndoChunk¶
digraph inheritance70196884d5 { rankdir=TB; ranksep=0.15; nodesep=0.15; size="8.0, 12.0"; "UndoChunk" [fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",URL="#pymel.core.system.UndoChunk",style="setlinewidth(0.5)",tooltip="Context manager for encapsulating code in a single undo.",height=0.25,shape=box,fontsize=8]; }
- class UndoChunk¶
Context manager for encapsulating code in a single undo.
Use in a with statement Wrapper for cmds.undoInfo(openChunk=1)/cmds.undoInfo(closeChunk=1)
>>> import pymel.core as pm >>> pm.ls("MyNode*", type='transform') [] >>> with pm.UndoChunk(): ... res = pm.createNode('transform', name="MyNode1") ... res = pm.createNode('transform', name="MyNode2") ... res = pm.createNode('transform', name="MyNode3") >>> pm.ls("MyNode*", type='transform') [nt.Transform(u'MyNode1'), nt.Transform(u'MyNode2'), nt.Transform(u'MyNode3')] >>> pm.undo() # Due to the undo chunk, all three are undone at once >>> pm.ls("MyNode*", type='transform') []