cwisbg

# snap to surface

Jul 17th, 2014
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. # snap to surface
  2. from pymel.core import *
  3. # select list, then snap to object
  4. sl = selected()  
  5. startL = spaceLocator(n="startL")
  6. endL = spaceLocator(n="endL")
  7. cp = createNode("closestPointOnMesh",n="snapperCheck")
  8. snapList = sl[:-1]
  9. snapto = sl[-1]
  10. snapto.getShape().worldMatrix[0] >> cp.inputMatrix
  11. startL.translate >> cp.inPosition
  12. cp.position >> endL.translate
  13. snapto.getShape().worldMesh[0] >> cp.inMesh
  14. for s in snapList:
  15.     st = s.getTranslation()
  16.     move(startL, st)
  17.     et = endL.getTranslation()
  18.     move(s,et)
  19. delete(cp,startL,endL)
Advertisement
Add Comment
Please, Sign In to add comment