简体   繁体   中英

Maya/Python: How do I scale multiple selected animation curves each from their own specific pivot point?

I'm trying to do a scale operation of multiple animation curves, each using its lowest key as the pivot point. I am thinking it should be a nested for loop structure but have not been able to get it working properly.

The scaling is simple, just:

mykeys = pm.keyframe( query=True, valueChange=True, absolute=True )
low = min(mykeys)
pm.scaleKey( valuePivot=low, valueScale=1.5 )

I am thinking it should be something similar to?

selectedCurves = pm.listConnections( t="animCurve")
for curve in selectedCurves:
    mykeys = pm.keyframe( query=True, valueChange=True, absolute=True )
    low = min(mykeys)
    pm.scaleKey( valuePivot=low, valueScale=1.5 )

Thanks in advance.

You have it right, you're just not telling the command to work on only one curve at a time:

selectedCurves = cmds.listConnections( t="animCurve")
for curve in selectedCurves:
    mykeys = cmds.keyframe(curve, query=True, valueChange=True, absolute=True )
    low = min(mykeys)
    cmds.scaleKey(curve, valuePivot=low, valueScale=1.5 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM