Skip to content

Instantly share code, notes, and snippets.

@patwooky
Last active September 9, 2017 17:32
Show Gist options
  • Save patwooky/040510f53f163393309c2912c88d5178 to your computer and use it in GitHub Desktop.
Save patwooky/040510f53f163393309c2912c88d5178 to your computer and use it in GitHub Desktop.
A PyMel script that creates a twisting line of cubes that gradually gets larger
import time
from pymel.core import *
def iterativeFunc(maxNum=20, size=(0.2, 1), rotAngle=(-20, 120)):
for n in range(maxNum):
myCube = polyCube(ch=False)
mySize = [size[0] + ((size[1] - size[0]) /float(maxNum) * n) for x in range(3)]
pos = [(size[1]*1.02) * n, 5, 0]
rot = [(float(rotAngle[1] - rotAngle[0])/maxNum)*n + rotAngle[0], 0, 0]
xform(myCube, t=pos, scale=mySize, rotation=rot)
time.sleep(0.01)
refresh(force=True)
return
iterativeFunc(maxNum=80, size=(0.06,2), rotAngle=(120, -120))
from pymel.core import *
import time
def recurse(counter, maxCounter):
pc = polyCube(ch=False)
maxSize = float(1)
startSize = float(0.2)
sc = (maxSize*startSize) + (maxSize*(1-startSize)/maxCounter)*counter
maxRotate = 270
xform(pc, scale=[sc, sc, sc], t=[counter*maxSize*1.005, 0, 0], rotation=[float(maxRotate)/maxCounter*counter, 0, 0] )
time.sleep(0.01)
refresh(force=True)
if counter >= maxCounter:
print counter, maxCounter
return
print counter
recurse(counter+1, maxCounter)
return
recurse(0, 40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment