Blog

Detect the Side of the Body That a Joint is on, Maya, Python, Function

Posted by:

  1. #This function will return the side of the body the passed joint is on
  2. #note, it assumes that the character is oriented down the Z axis with the joint's X transform being to either side of the character
  3. #assumes no nulls or intermediate joints exist above the joint being passed
  4.  
  5. import maya.cmds as cmds
  6.  
  7. def detectSideOfBody(jointToCalculate):
  8. transformPosition = cmds.xform(jointToCalculate, query = True, translation = True)
  9.  
  10. '''The following decides whether the selected joint is on the right or left hand side of the body acording to its position in X
  11. Note! this assumes that the skeleton was setup with the standard facing down the Z axis with Y being world up and
  12. X as the midline(saggital) axis.
  13. '''
  14. global globalSideOfBody
  15. if(transformPosition[0] > 0):
  16. sideOfBody = 'Lft'
  17. else:
  18. sideOfBody = 'Rt'
  19.  
  20. return sideOfBody

 

0
  Related Posts

You must be logged in to post a comment.