Created
April 12, 2015 10:55
-
-
Save petfactory/3f469919559840631bbe to your computer and use it in GitHub Desktop.
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 pymel.core as pm | |
pm.newFile(f=True) | |
# create the ctrl, add attr and set som keys | |
ctrl, _ = pm.circle(n='ctrl') | |
ctrl.addAttr('anim', k=True) | |
pm.setKeyframe(ctrl, v=0, attribute='anim', t=1) | |
pm.setKeyframe(ctrl, v=10, attribute='anim', t=25) | |
pm.setKeyframe(ctrl, v=0, attribute='anim', t=50) | |
# get a ref to global time | |
time = pm.PyNode('time1') | |
for i in range(10): | |
# add offset attr | |
ctrl.addAttr('offset{0}'.format(str(i)), k=True, dv=i*-2) | |
# pma to offset the time | |
pma = pm.createNode('plusMinusAverage') | |
# create node cache | |
cache = pm.createNode('frameCache') | |
# hook in the global time | |
time.outTime >> pma.input1D[0] | |
# subtract the offset value | |
pm.connectAttr('{0}.offset{1}'.format(ctrl, str(i)), pma.input1D[1]) | |
# hook up the output to the cache varyTime attr | |
pma.output1D >> cache.varyTime | |
# connect the animated attr to the strem | |
ctrl.anim >> cache.stream | |
cube, _ = pm.polyCube() | |
# set the varying output to drive the translate | |
cache.varying >> cube.ty | |
cube.tx.set(i*2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment