Skip to content

Instantly share code, notes, and snippets.

@benmorgantd
Created March 6, 2017 17:14
Show Gist options
  • Save benmorgantd/5cfed8faa89023e24043fbdf79a7a68a to your computer and use it in GitHub Desktop.
Save benmorgantd/5cfed8faa89023e24043fbdf79a7a68a to your computer and use it in GitHub Desktop.
Useful for when you want to set Maya SDK values to work beyond their keyed amount.
import maya.cmds as cmds
def setInfinite():
# get active attr in graph editor
activeAttr = cmds.animCurveEditor("graphEditor1GraphEd",q=1,cs=1)
if activeAttr:
for spline in activeAttr:
objName = spline[0:spline.index("_")]
attr = spline[spline.index("_")+1:]
keyAmt = cmds.keyframe(objName + "." + attr, q=1, keyframeCount = 1)
# set first and last key to Clamped in and out tangents
cmds.selectKey(spline,f=(0,0))
cmds.keyTangent(itt="clamped",ott="clamped")
cmds.selectKey(spline,f=(keyAmt-1,keyAmt-1))
cmds.keyTangent(itt="clamped",ott="clamped")
cmds.setInfinity(objName + "." + attr,pri="linear")
cmds.setInfinity(objName + "." + attr,poi="linear")
setInfinite()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment