def swapAnimation(fromNode, toNode):
if not mc.keyframe(fromNode, query=True, name=True):
mc.cutKey(toNode, clear=True)
return
attrs = mc.listAttr(fromNode, keyable=True)
if not attrs:
return
for attr in attrs:
if not mc.attributeQuery(attr, node=toNode, exists=True):
mc.cutKey(fromNode, attribute=attr, clear=True)
continue
fromPlug = '{}.{}'.format(fromNode, attr)
toPlug = '{}.{}'.format(toNode, attr)
srcCurve = mc.listConnections(fromPlug, source=True, destination=False, type='animCurve')
dstCurve = mc.listConnections(toPlug, source=True, destination=False, type='animCurve')
copySrc=None
copyDst=None
if srcCurve:
copySrc = mc.duplicate(srcCurve[0])[0]
if dstCurve:
copyDst = mc.duplicate(dstCurve[0])[0]
if copySrc:
try:
mc.cutKey(copySrc)
mc.pasteKey(toNode, attribute=attr, option='replaceCompletely')
except:pass
if copyDst:
try:
mc.cutKey(copyDst)
mc.pasteKey(fromNode, attribute=attr, option='replaceCompletely')
except:pass
for axis in getMirrorAxis(toNode):
mc.scaleKey(toNode, attribute=axis, valueScale=-1)
mc.scaleKey(fromNode, attribute=axis, valueScale=-1)
评论列表
文章目录