Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. '''
  2.  
  3. Description: Script well let you place a bone or locator at the average location of the two selected verticies
  4.  
  5. '''
  6. #!user/bin/env python
  7.  
  8. import maya.cmds as cmds
  9.  
  10. def averagePos(bone=0, loc=0):
  11.     #store the vert selection
  12.     vertSel = cmds.ls(sl=True)
  13.    
  14.     #Raise an error if nothing is selected
  15.     if not vertSel:
  16.         raise RuntimeError('No verticies were selected')
  17.  
  18.     clustSet = cmds.cluster(n='Dummy_Cluster')
  19.  
  20.     if clustSet:
  21.         if bone:
  22.             clear = cmds.select(clear=True)
  23.             mkjnt = cmds.joint(p=(0,0,0))
  24.             position = cmds.delete(cmds.pointConstraint('Dummy_Cluster', mkjnt, w=1)
  25.             cmds.delete(clustSet)
  26.         if loc:
  27.             clear = cmds.select(clear=True)
  28.             mkloc = cmds.spaceLocator(p=(0,0,0), n='Dummy_Position_LOC_')
  29.             position = cmds.delete(cmds.pointConstraint('Dummy_Cluster', mkjnt, w=1)
  30.             cmds.delete(clustSet)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement