当前位置: 首页>>代码示例>>Python>>正文


Python cmds.undo函数代码示例

本文整理汇总了Python中maya.cmds.undo函数的典型用法代码示例。如果您正苦于以下问题:Python undo函数的具体用法?Python undo怎么用?Python undo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了undo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testUndoRedo

    def testUndoRedo(self):
        """Tests that adaptors work with undo/redo."""
        cmds.file(new=True, force=True)
        cmds.group(name="group1", empty=True)
        adaptor = UsdMaya.Adaptor("group1")
        self.assertEqual(adaptor.GetAppliedSchemas(), [])

        # Do a single operation, then undo, then redo.
        adaptor.ApplySchema(UsdGeom.ModelAPI)
        self.assertEqual(adaptor.GetAppliedSchemas(), ["GeomModelAPI"])
        cmds.undo()
        self.assertEqual(adaptor.GetAppliedSchemas(), [])
        cmds.redo()
        self.assertEqual(adaptor.GetAppliedSchemas(), ["GeomModelAPI"])

        # Do a compound operation, then undo, then redo.
        cmds.undoInfo(openChunk=True)
        adaptor.ApplySchema(UsdGeom.MotionAPI).CreateAttribute(
                UsdGeom.Tokens.motionVelocityScale).Set(0.42)
        self.assertEqual(adaptor.GetAppliedSchemas(),
                ["GeomModelAPI", "MotionAPI"])
        self.assertAlmostEqual(adaptor.GetSchema(UsdGeom.MotionAPI).GetAttribute(
                UsdGeom.Tokens.motionVelocityScale).Get(), 0.42)
        cmds.undoInfo(closeChunk=True)
        cmds.undo()
        self.assertEqual(adaptor.GetAppliedSchemas(), ["GeomModelAPI"])
        self.assertFalse(adaptor.GetSchema(UsdGeom.MotionAPI).GetAttribute(
                UsdGeom.Tokens.motionVelocityScale))
        self.assertIsNone(adaptor.GetSchema(UsdGeom.MotionAPI).GetAttribute(
                UsdGeom.Tokens.motionVelocityScale).Get())
        cmds.redo()
        self.assertEqual(adaptor.GetAppliedSchemas(),
                ["GeomModelAPI", "MotionAPI"])
        self.assertAlmostEqual(adaptor.GetSchema(UsdGeom.MotionAPI).GetAttribute(
                UsdGeom.Tokens.motionVelocityScale).Get(), 0.42)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:35,代码来源:testUsdMayaAdaptor.py

示例2: __exit__

 def __exit__(self, exc_type, exc_value, traceback):
     '''Close the opened chunk and undo everything that had been captured.'''
     cmds.undoInfo(closeChunk=True)
     try:
         cmds.undo()
     except RuntimeError:
         pass
开发者ID:ColinKennedy,项目名称:env,代码行数:7,代码来源:undo_context.py

示例3: componentSelectionInOrder

def componentSelectionInOrder():
	'''
	Returns a list of the selected components in the order they were selected.
	'''
	# Get selection
	selection = []
	selectionAll = mc.ls(sl=1)
	lastCommand = mc.undoInfo(q=True,un=True)
	counter = 0
	
	# Traverse undo list
	while lastCommand.count('select'):
		lastCommand = mc.undoInfo(q=True,un=True)
		if lastCommand.count('select'):
			selectElem = lastCommand.split(' ')
			selection.append(selectElem[2])
			mc.undo()
	
	# Sort selection
	selection.reverse()
	realSelection = []
	[realSelection.append(i) for i in selection if not realSelection.count(i)]
	
	# Return result
	return realSelection
开发者ID:auqeyjf,项目名称:glTools,代码行数:25,代码来源:selection.py

示例4: jobUndo

def jobUndo(*args):
    # need to reset globals if an undo is detected
    que = cmds.undoInfo(q=1, rn=1)
    if 'import curveSoftSelect as css' in que or 'jobValue' in que:
        cmds.undo()
    killValueJob()
    activateValueJob()
开发者ID:boochos,项目名称:work,代码行数:7,代码来源:curveSoftSelect.py

示例5: orientJoints

 def orientJoints(s):
     """
     Face joints in the correct direction.
     """
     sel = cmds.ls(sl=True)
     err = cmds.undoInfo(openChunk=True)
     try:
         markers = s.markers
         joints = markers.keys()
         with ReSeat(joints):
             for j in joints:
                 m = markers[j]
                 if cmds.objExists(m.marker) and cmds.objExists(j):
                     with Isolate(j):
                         m.setJoint()
                         try:
                             cmds.makeIdentity(
                                 j,
                                 apply=True,
                                 r=True) # Freeze Rotations
                         except RuntimeError:
                             pass
                 else: # User deleted marker / joint. Stop tracking.
                     m.removeMarker()
                     del markers[j]
             cmds.select(sel, r=True)
     except Exception as err:
         raise
     finally:
         cmds.undoInfo(closeChunk=True)
         if err: cmds.undo()
开发者ID:internetimagery,项目名称:twinSkeleton,代码行数:31,代码来源:fixorient.py

示例6: rsReAtt

def rsReAtt():
    l_oSels = rsObjList()
    l_AttributeList = (cmds.textScrollList("rsAttributeScroll", query=True, allItems=True))
    for s_Att in l_AttributeList:
        s_orig = l_oSels[0] + "." + s_Att
        i_LockState = cmds.getAttr(s_orig, lock=True)
        if i_LockState:
            cmds.setAttr(s_orig, lock=False)
        l_paramDest = cmds.listConnections(s_orig, plugs=True, destination=True, source=True)
        l_paramDestLock = []
        if l_paramDest:
            for z in range(len(l_paramDest)):
                l_paramDestLock.append(cmds.getAttr(l_paramDest[z], lock=True))
                if l_paramDestLock[z]:
                    cmds.setAttr(l_paramDest[z], lock=False)
        cmds.deleteAttr(l_oSels[0], at=s_Att)
        cmds.undo()
        if l_paramDest:
            for z in range(len(l_paramDest)):
                l_paramDestLock.append(cmds.getAttr(l_paramDest[z], lock=True))
                if l_paramDestLock[z]:
                    cmds.setAttr(l_paramDest[z], lock=True)
        if i_LockState:
            cmds.setAttr(s_orig, lock=True)
    cmds.select(cl=True)
    cmds.select(l_oSels[0], r=True)
    return True
开发者ID:RigStudio,项目名称:rsEditAttributes,代码行数:27,代码来源:rsEditAttributes.py

示例7: wrapper

 def wrapper(*args, **kw):
     with self:
         try:
             return f(*args, **kw)
         except:
             if rollback:
                 mc.undo()
             raise
开发者ID:TianD,项目名称:ogTools,代码行数:8,代码来源:mayaDecorators.py

示例8: bakeShader

 def bakeShader(self, shader, cmd):
     self.createShaders()
     cmds.undoInfo(openChunk=True)
     self.assignShader(shader)
     self.setAttributes(shader)
     mel.eval(cmd)
     cmds.undoInfo(closeChunk=True)
     cmds.undo()
开发者ID:Regnareb,项目名称:Maya,代码行数:8,代码来源:bakery.py

示例9: fix_shaders

def fix_shaders():
    """
    Fixing a bug in maya where a referenced maya file loses it's shaders. Mesh needs to be selected
    """
    get_selected(scriptEditorWarning=True)
    mel.eval("sets -e -forceElement initialShadingGroup;")
    cmds.undo()
    pm.select(cl=1)
开发者ID:pritishd,项目名称:PKD_Tools,代码行数:8,代码来源:libUtilities.py

示例10: undoSel

def undoSel():
    sel = cmds.ls(sl=True)
    info = cmds.undoInfo(q=True, un=True)
    if 'selectKey' in info:
        return None
    elif 'select' in info:
        cmds.undo()
        cmds.select(clear=True)
        cmds.select(sel)
        return True
开发者ID:boochos,项目名称:work,代码行数:10,代码来源:pairSelect.py

示例11: test_undoPerformance

    def test_undoPerformance( self ):
        import time
        iterations = 35
        maxdepth = 3
        totalops = 0

        all_elapsed = [list(),list()]

        for undoEnabled in range( 2 ):

            undo = ""
            if not undoEnabled:
                undo = "Undo disabled"

            cmds.undoInfo( st=undoEnabled )

            # decorated !
            starttime = time.time()
            numops = TestUndoPerformance._recurseUndoDeco( iterations, 0, maxdepth )
            totalops += numops
            elapsed = time.time() - starttime
            all_elapsed[undoEnabled].append( elapsed )

            print >> sys.stderr, "UNDO: DECORATED %s: %i ops in %f s ( %f / s )" % ( undo, numops, elapsed, numops / elapsed )


            starttime = time.time()
            numops = TestUndoPerformance._recurseUndo( iterations, 0, maxdepth )
            totalops += numops
            elapsed_deco = elapsed
            elapsed = time.time() - starttime
            all_elapsed[undoEnabled].append( elapsed )

            print >> sys.stderr, "UNDO: MANUAL %s: %i ops in %f s ( %f / s )" % ( undo, numops, elapsed, numops / elapsed )
            starttime = time.time()

            print >> sys.stderr, "UNDO: DECORATED is %f %% faster than manually implemented functions !" % ( 100 - ( elapsed_deco / elapsed ) * 100 )

            if undoEnabled:
                cmds.undo()
                cmds.undo()
                cmds.redo()
                cmds.redo()
                elapsed = time.time() - starttime

                print >> sys.stderr, "UNDO: CALL TIME: %i operations in %f s ( %f / s )" % ( totalops, elapsed, totalops / elapsed )
            #END if undo enabled
        # END for each undo queue state

        ratio = 100.0 - ( ( all_elapsed[0][0] / all_elapsed[1][0] ) * 100 )
        difference = all_elapsed[1][1] - all_elapsed[0][1]

        # RATIOS between enabled undo system and without
        print >> sys.stderr, "UNDO: RATIO UNDO QUEUE ON/OFF: %f s (on) vs %f s (off) = %f %% speedup on disabled queue ( difference [s] = %f )" % (all_elapsed[1][0], all_elapsed[0][0], ratio, difference )
开发者ID:mrv-developers,项目名称:mrv,代码行数:54,代码来源:test_undo.py

示例12: mel_handler

 def mel_handler(self, input_str):
     prev_chunk = cmds.undoInfo(q=True, chunkName=True)
     cmds.undoInfo(openChunk=True)
     try:
         execInMain(partial(mel.eval, input_str))
         cmds.repeatLast(addCommand=input_str)
         cmds.undoInfo(closeChunk=True)
     except:
         cmds.undoInfo(closeChunk=True)
         if not cmds.undoInfo(q=True, chunkName=True) == prev_chunk:
             cmds.undo()
         raise
开发者ID:juggernate,项目名称:hotline,代码行数:12,代码来源:mayacontext.py

示例13: moveToBottom

def moveToBottom(attribute):
    """
	Move specified attribute to the bottom of the channel box
	"""
    # Determine object and attribute names from input argument
    obj = attribute.split(".")[0]
    attr = attribute.split(".")[-1]

    # Delete attribute temporarily
    mc.deleteAttr(obj, attribute=attr)

    # Undo deletion
    mc.undo()
开发者ID:auqeyjf,项目名称:glTools,代码行数:13,代码来源:attribute.py

示例14: test_removeChild

    def test_removeChild(self):
        base = nt.createNode("base" , "transform")
        trans = nt.createNode("base|trans", "transform")
        mesh = nt.createNode("base|mesh", "mesh")

        for item in [trans, mesh]:
            removeditem = base.removeChild(item, allowZeroParents=True)

            # PATHS ARE INVALID NOW - object is nowhere to be found
            assert not removeditem.isValid() and removeditem.isAlive() 

            cmds.undo()
            assert removeditem.isValid() and removeditem.isAlive() 
开发者ID:mrv-developers,项目名称:mrv,代码行数:13,代码来源:test_base.py

示例15: py_handler

 def py_handler(self, input_str):
     prev_chunk = cmds.undoInfo(q=True, chunkName=True)
     cmds.undoInfo(openChunk=True)
     try:
         execInMain(input_str)
         setattr(__main__, "last_py_cmd", input_str)
         cmds.repeatLast(addCommand='python("execInMain(last_py_cmd)")')
         cmds.undoInfo(closeChunk=True)
     except:
         cmds.undoInfo(closeChunk=True)
         if not cmds.undoInfo(q=True, chunkName=True) == prev_chunk:
             cmds.undo()
         raise
开发者ID:juggernate,项目名称:hotline,代码行数:13,代码来源:mayacontext.py


注:本文中的maya.cmds.undo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。