cwisbg

Orient

Aug 28th, 2014
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. # Orient stuff in maya
  2. # Select two objects, or components, and run. Will create a locator oriented along the two points
  3. # cwisbg.com
  4. from pymel.core import *
  5. def getPiv(s):
  6.     select(s)
  7.     setToolTo('Move')
  8.     piv = manipMoveContext('Move', q=True, p=True,m=2)  
  9.     return piv
  10. def orient(point1, point2):
  11.     l1 = spaceLocator(p = (0,0,0), n = "point1")
  12.     move(l1, point1, ws=1)
  13.     l2 = spaceLocator(p = (0,0,0), n = "point2")
  14.     move(l2, point2, ws=1)
  15.     aimConstraint(l1,l2)
  16.     axesLctr = spaceLocator(p = (0,0,0), n = "axes")
  17.     print l1
  18.     p = pointConstraint([l1,l2], axesLctr)
  19.     r = l2.getRotation()
  20.     rotate(axesLctr,r)
  21.     delete(p)
  22.     delete(l1)
  23.     delete(l2)
  24. sl = selected()
  25. point1 = getPiv(sl[0])
  26. point2 = getPiv(sl[1])
  27. orient(point1, point2)
  28. print "done"
Advertisement
Add Comment
Please, Sign In to add comment