Skip to content

Instantly share code, notes, and snippets.

@bohdon
Created January 24, 2023 19:17
Show Gist options
  • Save bohdon/1273d97ffc88e424dcfe620040ec6e48 to your computer and use it in GitHub Desktop.
Save bohdon/1273d97ffc88e424dcfe620040ec6e48 to your computer and use it in GitHub Desktop.
Center a twist joint between it's parent joint and an end joint in Maya.
import pymel.core as pm
def center_twist_joint(twist_joint, end_joint):
"""
Center a twist joint between it's parent and an end joint
"""
root_joint = twist_joint.getParent()
center = (root_joint.getTranslation(space='world') + end_joint.getTranslation(space='world')) / 2.0
twist_joint.setTranslation(center, space='world')
# select end joint, then twist joint
center_twist_joint(pm.selected()[1], pm.selected()[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment