Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 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. class avrPos:
  10.     def __init__(self):
  11.         #Creat the window, but first check to see if its created, if so, then delete it first
  12.         if cmds.window('OG_PosPlace_v1.0', q=True, exists=True):
  13.             cmds.deleteUI('OG_PosPlace_v1.0', window=True)
  14.            
  15.         posGUI = cmds.window( title='OG_Pos_Place_v1.0', iconName='OG_POS', w=170, h=170, s=False)
  16.        
  17.         if cmds.windowPref( posGUI, exists=True):
  18.             cmds.windowPref( posGUI, remove=True)
  19.            
  20.         posTypeForm = cmds.formLayout(numberOfDivisions=100)
  21.        
  22.         self.text1 = cmds.text( label='Select the verticies you want to position your utility!')
  23.        
  24.         pushButton = cmds.button( label="Place Joint", w=50, h=50)
  25.        
  26.         moveButtons = cmds.formLayout( posGUI, edit=True, attachForm=[(pushButton, 'bottom', 10), (pushButton, 'left', 45)])
  27.        
  28.        
  29.        
  30.         cmds.showWindow( posGUI )
  31.        
  32.     def averagePos(self,bone=0, loc=0):
  33.         #store the vert selection
  34.         vertSel = cmds.filterExpand( ex=True, sm=31)
  35.    
  36.         #Raise an error if nothing is selected
  37.         if not vertSel:
  38.             raise RuntimeError('No verticies were selected')
  39.  
  40.         clustSet = cmds.cluster(n='Dummy_Cluster')
  41.  
  42.         cmds.select(clear=True)
  43.         if clustSet:
  44.             if bone:
  45.                 mkobj = cmds.joint(p=(0,0,0))
  46.  
  47.             if loc:
  48.                 mkobj = cmds.spaceLocator(p=(0,0,0), n='Dummy_Position_LOC_')
  49.                
  50.             position = cmds.delete(cmds.pointConstraint(mkobj, mkjnt, w=1))
  51.             cmds.delete(clustSet)
  52.                
  53. if __name__=='__main__':
  54.     arvPos()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement