Last active
August 29, 2015 14:01
-
-
Save tokejepsen/bdec04c8085f59c3e140 to your computer and use it in GitHub Desktop.
rigFix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import Tapp.Maya.Red9.core.Red9_AnimationUtils as r9Anim | |
import Tapp.Maya.Red9.core.Red9_CoreUtils as r9Core | |
def switchRotationAxis(node, axis1, axis2, axis1Inverse, axis2Inverse): | |
#variables | |
temp = cmds.spaceLocator() | |
#copying all animation | |
sf = int(cmds.findKeyframe(node, which="first")) | |
ef = int(cmds.findKeyframe(node, which="last")) | |
cmds.copyKey(node, time=(sf, ef)) | |
cmds.pasteKey(temp) | |
#copy axis1 to axis2 | |
cmds.copyKey(temp, attribute=('r' + axis1), time=(sf, ef)) | |
cmds.pasteKey(node, attribute=('r' + axis2), option='replace') | |
cmds.scaleKey(node, attribute=('r' + axis2), time=(sf, ef), | |
valueScale=axis1Inverse, valuePivot=0) | |
cmds.copyKey(temp, attribute=('t' + axis1), time=(sf, ef)) | |
cmds.pasteKey(node, attribute=('t' + axis2), option='replace') | |
cmds.scaleKey(node, attribute=('t' + axis2), time=(sf, ef), | |
valueScale=axis1Inverse, valuePivot=0) | |
#copy axis2 to axis1 | |
cmds.copyKey(temp, attribute=('r' + axis2), time=(sf, ef)) | |
cmds.pasteKey(node, attribute=('r' + axis1), option='replace') | |
cmds.scaleKey(node, attribute=('r' + axis1), time=(sf, ef), | |
valueScale=axis2Inverse, valuePivot=0) | |
cmds.copyKey(temp, attribute=('t' + axis2), time=(sf, ef)) | |
cmds.pasteKey(node, attribute=('t' + axis1), option='replace') | |
cmds.scaleKey(node, attribute=('t' + axis1), time=(sf, ef), | |
valueScale=axis2Inverse, valuePivot=0) | |
#setting rotationOrder | |
orderList = ['xyz', 'yzx', 'zxy', 'xzy', 'yxz', 'zyx'] | |
axis3 = 'xyz'.replace(axis1, '') | |
axis3 = axis3.replace(axis2, '') | |
ro = axis2 + axis1 + axis3 | |
cmds.setAttr(node + '.rotateOrder', orderList.index(ro)) | |
#cleanup | |
cmds.delete(temp) | |
cmds.file('Y:/projects/8-bit Bots/production/library/characters/penny/penny.rig.v007.ma', | |
r=True, namespace='penny_rig') | |
cmds.select('penny_rig_v001:world_cnt', 'penny_rig:world_cnt') | |
settings = r9Core.FilterNode_Settings() | |
settings.nodeTypes = 'nurbsCurve' | |
animFuncs = r9Anim.AnimFunctions() | |
animFuncs.copyKeys(nodes=cmds.ls(sl=True), time=r9Anim.timeLineRangeGet(), | |
filterSettings=settings) | |
switchRotationAxis('penny_rig:neck01_cnt', 'y', 'z', -1, 1) | |
switchRotationAxis('penny_rig:neck02_cnt', 'y', 'z', 1, -1) | |
switchRotationAxis('penny_rig:head_cnt', 'x', 'y', -1, 1) | |
cmds.file('Y:/projects/8-bit Bots/production/library/characters/penny/penny.rig.v001.ma', | |
removeReference=True) | |
refNode = cmds.file('Y:/projects/8-bit Bots/production/library/characters/penny/penny.rig.v007.ma', | |
q=True, referenceNode=True) | |
cmds.file('Y:/projects/8-bit Bots/production/library/characters/penny/penny.rig.v010.ma', | |
loadReference=refNode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment