本文整理汇总了Python中maya.cmds.undo函数的典型用法代码示例。如果您正苦于以下问题:Python undo函数的具体用法?Python undo怎么用?Python undo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了undo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_displaySettings
def test_displaySettings(self):
mrvmaya.Scene.new(force = 1)
mesh = nt.createNode("a1|b1|c1|d1|mesh", "mesh")
mesh.tmp.msetInt(1)
# TEMPLATE
##########
assert mesh.isTemplate()
cmds.undo()
assert not mesh.isTemplate()
a1 = mesh.root()
a1.v.msetInt(0)
# VISIBLE
#########
assert not mesh.isVisible()
cmds.undo()
assert mesh.isVisible()
# DRAWING OVERRIDES
###################
a1.do.mchildByName('ove').msetInt(1)
a1.do.mchildByName('ovdt').msetInt(2)
assert mesh.displayOverrideValue('ovdt') == 2
cmds.undo()
cmds.undo()
assert mesh.displayOverrideValue('ovdt') == None
开发者ID:mrv-developers,项目名称:mrv,代码行数:28,代码来源:test_base.py
示例17: assert_values
def assert_values(fgetname, fsetname, loose):
getter = getattr(p, fgetname)
v = getter()
assert isinstance(v, api.MVector)
nv = api.MVector(i+v.x+1.0, i+v.y+2.0, i+v.z+3.0)
getattr(p, fsetname)(nv)
cmp_val(nv, getter(), loose)
cmds.undo()
cmp_val(v, getter(), loose)
cmds.redo()
cmp_val(nv, getter(), loose)
开发者ID:mrv-developers,项目名称:mrv,代码行数:14,代码来源:test_base.py
示例18: testComplexSetAssemblyChangeReps
def testComplexSetAssemblyChangeReps(self):
"""
This tests that changing representations of a USD reference assembly
node in Maya that references a complex hierarchy of different types of
prims works as expected, including undo'ing and redo'ing representation
changes.
"""
assemblyNode = self._SetupScene('ComplexSet.usda', '/ComplexSet')
# No representation has been activated yet, so ensure the assembly node
# has no children.
self._ValidateUnloaded(assemblyNode)
# Change representations to 'Collapsed' and validate.
cmds.assembly(assemblyNode, edit=True, active='Collapsed')
self._ValidateCollapsed(assemblyNode)
# Change representations to 'Cards' and validate.
cmds.assembly(assemblyNode, edit=True, active='Cards')
self._ValidateCards(assemblyNode)
# Change representations to 'Expanded' and validate.
cmds.assembly(assemblyNode, edit=True, active='Expanded')
self._ValidateComplexSetExpandedTopLevel(assemblyNode)
# Change representations to 'Full' and validate.
cmds.assembly(assemblyNode, edit=True, active='Full')
self._ValidateComplexSetFullTopLevel(assemblyNode)
# Undo and the node should be back to Expanded.
cmds.undo()
self._ValidateComplexSetExpandedTopLevel(assemblyNode)
# Undo and the node should be back to Cards.
cmds.undo()
self._ValidateCards(assemblyNode)
# Undo and the node should be back to Collapsed.
cmds.undo()
self._ValidateCollapsed(assemblyNode)
# Undo once more and no representation should be active.
cmds.undo()
self._ValidateUnloaded(assemblyNode)
# Redo and it's back to Collapsed.
cmds.redo()
self._ValidateCollapsed(assemblyNode)
# Redo and it's back to Cards.
cmds.redo()
self._ValidateCards(assemblyNode)
# Redo again and it's back to Expanded.
cmds.redo()
self._ValidateComplexSetExpandedTopLevel(assemblyNode)
# Redo once more and it's back to Full.
cmds.redo()
self._ValidateComplexSetFullTopLevel(assemblyNode)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:60,代码来源:testUsdReferenceAssemblyChangeRepresentations.py
示例19: bake
def bake(self):
for shader, attr in self.shaders.items():
t = initstats.emit('bake', True)
assignation = attr[0]
path = attr[1]
texture = attr[2]
Umin, Vmin = tdLib.getUDIM(assignation)
with tdLib.UndoContext():
assignation = self.extract_combine(assignation)
dummyFile = cmds.convertSolidTx(texture + '.outColor', assignation, fileImageName=path, antiAlias=1, backgroundMode=2, resolutionX=512, resolutionY=512, fileFormat='tga', uvRange=[Umin, Umin+1, Vmin, Vmin+1])
cmds.undo()
self.reinitialise_texture()
logger.info(self.create_high(path))
logger.info(path)
t.stop()
开发者ID:Regnareb,项目名称:Maya,代码行数:15,代码来源:placeholder.py
示例20: _ValidateAllModelRepresentations
def _ValidateAllModelRepresentations(self, nodeName):
"""
Tests all representations of an assembly node that references a
model (i.e. has no sub-assemblies). This should apply for both a
standalone model reference node as well as a nested assembly reference
node that references a model.
"""
# No representation has been activated yet, so ensure the assembly node
# has no children.
self._ValidateUnloaded(nodeName)
# Change representations to 'Collapsed' and validate.
cmds.assembly(nodeName, edit=True, active='Collapsed')
self._ValidateCollapsed(nodeName)
# Change representations to 'Cards' and validate.
cmds.assembly(nodeName, edit=True, active='Cards')
self._ValidateCards(nodeName)
# Change representations to 'Expanded' and validate.
cmds.assembly(nodeName, edit=True, active='Expanded')
self._ValidateModelExpanded(nodeName)
# Change representations to 'Full' and validate.
cmds.assembly(nodeName, edit=True, active='Full')
self._ValidateModelFull(nodeName)
# Undo and the node should be back to Expanded.
cmds.undo()
self._ValidateModelExpanded(nodeName)
# Undo and the node should be back to Cards.
cmds.undo()
self._ValidateCards(nodeName)
# Undo and the node should be back to Collapsed.
cmds.undo()
self._ValidateCollapsed(nodeName)
# Undo once more and no representation should be active.
cmds.undo()
self._ValidateUnloaded(nodeName)
# Redo and it's back to Collapsed.
cmds.redo()
self._ValidateCollapsed(nodeName)
# Redo and it's back to Cards.
cmds.redo()
self._ValidateCards(nodeName)
# Redo again and it's back to Expanded.
cmds.redo()
self._ValidateModelExpanded(nodeName)
# Redo once more and it's back to Full.
cmds.redo()
self._ValidateModelFull(nodeName)
开发者ID:PixarAnimationStudios,项目名称:USD,代码行数:58,代码来源:testUsdReferenceAssemblyChangeRepresentations.py
注:本文中的maya.cmds.undo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论