Skip to content

Instantly share code, notes, and snippets.

@masqu3rad3
Created August 19, 2020 10:55
Show Gist options
  • Save masqu3rad3/572dd34c7d9a5c146c144ce5e32e6692 to your computer and use it in GitHub Desktop.
Save masqu3rad3/572dd34c7d9a5c146c144ce5e32e6692 to your computer and use it in GitHub Desktop.
quick dirty whip kind of overlapping animation
from maya import cmds
def whip(node_list, attr_holder=None, offset=5, diminish=0.8, attr_list=["rx", "ry", "rz"]):
if type(node_list) is not list:
cmds.error("node_list must be a list variable. duh...")
if len(node_list) < 2:
cmds.error("node_list must contain at least 2 elements. duh...")
if not attr_holder:
attr_holder = node_list[0]
cmds.addAttr(attr_holder, at="float", ln="powerDim", min=0, max=1, defaultValue=0.8, k=True)
for attr in attr_list:
cmds.addAttr(attr_holder, at="float", ln="offsetMult_%s" %attr, defaultValue=1, k=True)
for nmb, node in enumerate(node_list[1:]):
print("*"*30)
print(nmb, node, node_list[nmb])
print("*"*30)
for attr in attr_list:
frame_cache = cmds.createNode("frameCache", name = "%s_frameCache" % node)
power_mult = cmds.createNode("multDoubleLinear", name ="%s_powerlose" % node)
master_mult = cmds.createNode("multDoubleLinear", name="%s_%s_masterMult" % (attr_holder, attr))
cmds.connectAttr("%s.%s" %(node_list[nmb], attr), "%s.input1" %power_mult)
cmds.connectAttr("%s.powerDim" % attr_holder, "%s.input2" % power_mult)
cmds.connectAttr("%s.output" % power_mult, "%s.input1" % master_mult)
cmds.connectAttr("%s.%s" %(attr_holder, "offsetMult_%s" % attr), "%s.input2" % (master_mult))
cmds.connectAttr("%s.output" % master_mult, "%s.stream" % frame_cache)
cmds.connectAttr("%s.past[%s]" %(frame_cache, int(offset_value)), "%s.%s" % (node, attr))
def whip_refresh():
frame_caches=cmds.ls(type="frameCache")
for cache in frame_caches:
cmds.setAttr("%s.nodeState" %cache, 1)
# cmds.refresh()
cmds.setAttr("%s.nodeState" %cache, 0)
# cmds.refresh()
whip(cmds.ls(sl=True))
whip_refresh()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment