Skip to content

Instantly share code, notes, and snippets.

@blockinhead
Created October 15, 2020 13:59
Show Gist options
  • Select an option

  • Save blockinhead/86d03a060357a50ffd804de0ef2016eb to your computer and use it in GitHub Desktop.

Select an option

Save blockinhead/86d03a060357a50ffd804de0ef2016eb to your computer and use it in GitHub Desktop.
pymel demo script to animate vertices of selected mesh
import pymel.core as pm
from random import uniform
def tremor_curve(src_curve, frame_step, amplitude):
num_keys = src_curve.numKeys()
min_frame = src_curve.getTime(0)
max_frame = src_curve.getTime(num_keys - 1)
for f in range(int(min_frame) + frame_step, int(max_frame), frame_step):
cur_val = src_curve.evaluate(f)
src_curve.addKey(f, cur_val + amplitude * uniform(-1, 1))
shape = pm.selected()[0].getShape()
for v in shape.vtx:
print v.index()
curve = pm.createNode('animCurveTL', skipSelect=True)
curve.output >> shape.pnts[v.index()].pntx
curve.addKeys((0, 25), (0, 0))
tremor_curve(curve, 3, 0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment