cwisbg

MoPath

Sep 23rd, 2020
1,046
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # select curve, duplicated objects in group named "duper"
  2. from pymel.core import *
  3. import maya.cmds as cmds
  4. def grpr(name):
  5.     g = ls(name)
  6.     if g:
  7.         delete(g)
  8.     g = group(n=name,em=1)
  9.     return g  
  10. pathObj = ls("duper")
  11. # Main Attributes
  12. startFrame = 1
  13. speed = 1
  14. objSpacing = 4
  15. fadingScale = .05
  16. sl = selected()
  17. newGrp = grpr("DuperGrper")
  18. toSelect = []
  19. for s in sl:
  20.     offsetBy = 0
  21.     pathLen = arclen(s)
  22.     endFrame = pathLen * speed
  23.     offsetAmnt = objSpacing * speed
  24.     objAmnt = int((pathLen/offsetAmnt)* speed)
  25.     for d in range(0,objAmnt):  
  26.         dup = duplicate(pathObj)
  27.         parent(dup[0], newGrp)    
  28.         scaleStart = startFrame+offsetBy
  29.         scaleEnd = endFrame+offsetBy
  30.         keyOffseter = startFrame + endFrame * fadingScale
  31.        
  32.         moPath = pathAnimation(dup, c = s ,startTimeU = scaleStart, endTimeU = scaleEnd, follow=1, fm=1,fa="x")
  33.        
  34.         # Fading keys
  35.         setKeyframe(dup[0]+".scale", t = startFrame+offsetBy, v = 0.1)
  36.         setKeyframe(dup[0]+".scale", t = startFrame+offsetBy+keyOffseter, v=1)
  37.         setKeyframe(dup[0]+".scale", t = endFrame+offsetBy-keyOffseter, v=1)
  38.         setKeyframe(dup[0]+".scale", t = endFrame+offsetBy, v=.1)
  39.  
  40.         animCrv = listConnections(moPath)[0]
  41.  
  42.  
  43.         keyTangent(animCrv, itt = "linear", ott = "linear")  
  44.  
  45.         #keyMiddle = ((startFrame+offsetBy) + (endFrame+offsetBy)) *.5
  46.         #setKeyframe(animCrv, t = keyMiddle, v = 0.5, itt="slow", ott="slow")  
  47.          
  48.         sk = selectKey(animCrv)
  49.         dk = selectKey(dup, add=1)
  50.         setInfinity( poi = "cycle", pri = "cycle")
  51.    
  52.         offsetBy += offsetAmnt
  53.  
  54.  
RAW Paste Data