Expose

Download exposer.py

python, pyfuncs, maya

This script can be useful to debug stretch / squash rigging or twist rigging to see effect on skinned object.

This is an example of using this function, this will create a cylinder for each selected joints, with a radius of 2

1
expose(cmds.ls(sl=True), 2)

Here is the full code ;

select
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def expose(jts, radius=1.0, hard=False):
    """
    create a cylinder for each joint selected
    :param    jts: joints list
    :param radius: radius of cylinders
    :param   hard: skinning with child of the joint or no

    :return      : cylinders' names
    """
    meshes = []
    for jt in jts:
        desc = cmds.listRelatives(jt, c=True, type='joint')
        if not desc:
            desc = cmds.pickWalk(jt, d='right')
            if not desc:
                continue
            else:
                desc = desc[-1]
        else:
            desc = desc[-1]
        d = cmds.getAttr('%s.tx' % desc) if desc else 1
        cyl = cmds.polyCylinder(n='expose_%s' % jt, radius=radius, h=d, sx=8)[0]
        meshes.append(cyl)
        cmds.delete(cmds.pointConstraint(jt, desc, cyl, w=0.5, mo=False))
        cmds.delete(cmds.orientConstraint(jt, cyl, w=1.0, mo=False))
        cmds.rotate(0, 0, 90, cyl, os=True, relative=True)
        jts = [jt] if hard else [jt, desc]
        sc = cmds.skinCluster(cyl, jts, tsb=True, mi=2,
                              dr=radius, omi=False, nw=True)[0]
        if not hard:
            cmds.skinPercent(sc, '%s.vtx[0:7]' % cyl, tv=[desc,1.0])

    return meshes

If you have any questions... =)