cwisbg

Locator

Jan 28th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. # Locator at pivot
  2. # cwisbg.com
  3. from pymel.core import *
  4. currentSceneScale = currentUnit(q=1, l=1)
  5. tempSceneScale = currentUnit(l = "cm")
  6. def getPiv(s, type):
  7.     if type == "transform":
  8.         papCheck = listRelatives(s,p=1)
  9.         if papCheck:
  10.             try:
  11.                 parent(s,w=1)
  12.                 rot = s.getRotation()
  13.                 parent(s, papCheck)
  14.             except:
  15.                 pass
  16.         else:
  17.             rot = s.getRotation()
  18.     else:
  19.         rot = [0,0,0]        
  20.     select(s)
  21.     setToolTo('Move')
  22.     piv = manipMoveContext('Move', q=True, p=True,m=2)
  23.     return piv, rot
  24. sl = selected()
  25. type = nodeType(sl[0])
  26. print type
  27. if type == "mesh":
  28.     t , r = getPiv(sl, type)
  29.     l = spaceLocator(p = (0,0,0), n = "{0}_saveLocation".format(sl[0]))
  30.     move(l, t, ws=1)
  31.     rotate(l, r)
  32. else:    
  33.     for s in sl:
  34.         type = nodeType(s)
  35.         t , r = getPiv(s, type)
  36.         l = spaceLocator(p = (0,0,0), n = "{0}_saveLocation".format(s))
  37.         move(l, t, ws=1)
  38.         rotate(l, r)
  39. currentUnit(l = currentSceneScale)
  40. print "done"
Advertisement
Add Comment
Please, Sign In to add comment