cwisbg

Batch aim

Jun 3rd, 2014
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. # Batch aim
  2. # Select objects, then target
  3. from pymel.core import *
  4. def getPiv(s):
  5.     currentSceneScale = currentUnit(q=1, l=1)
  6.     tempSceneScale = currentUnit(l = "cm")
  7.     select(s)
  8.     setToolTo('Move')
  9.     piv = manipMoveContext('Move', q=True, p=True,m=2)  
  10.     return piv
  11.     currentUnit(l = currentSceneScale)
  12. def makeBufferGrp(s):  
  13.     cl = getPiv(s)
  14.     p = listRelatives(s,p=1)
  15.     g = group(n="{0}_bufferGrp".format(s),em=1)
  16.     move(g, cl)
  17.     oc = orientConstraint(s,g)
  18.     delete(oc)
  19.     if p:
  20.         parent(g, p)
  21.     parent(s, g)
  22.     return g
  23. sl = selected()
  24. aimList = sl[:-1]
  25. aimer = sl[-1]
  26. for s in aimList:
  27.     g = makeBufferGrp(s)
  28.     ac = aimConstraint(aimer, g,weight=1 ,aimVector =[0 ,0, -1], upVector= [0, 1, 0], worldUpType="scene")
Advertisement
Add Comment
Please, Sign In to add comment