pymel.core.system.undo

undo(*args, **kwargs)

Takes the most recent command from the undo list and undoes it.

Derived from mel command maya.cmds.undo

Example:

import pymel.core as pm

# In this particular example, each line needs to be executed
# separately one after the other. Executing lines separately
# guaranties that commands are properly registered in the undo
# stack.

pm.polyCube()
# Result: [nt.Transform(u'pCube1'), nt.PolyCube(u'polyCube1')] #

pm.polySphere()
# Result: [nt.Transform(u'pSphere1'), nt.PolySphere(u'polySphere1')] #

pm.undo()
# Undo: pm.polySphere()
 #

pm.undo()
# Undo: pm.polyCube()
 #