Maya Rigging Tips: Using jointOrient and changing shape-node's parent and hierarchical position

I had a nice discussion with my rigger friend and found out neat way of setting up rotation controllers with less offset nodes. ;p

Sample code A:

def sample():
    import maya.cmds as mc;
    # Regacy using an offset node
    c01= mc.circle(n="RotateA_regacy")[0];
    c02= mc.circle(n="RotateB_regacy")[0];
    os01= mc.ls(mc.parent(mc.group(em=1,n="offset"),c01),sl=1,l=1)[0];
    c02= mc.ls(mc.parent(c02,os01),sl=1,l=1);
    mc.setAttr(os01+".rx",90);
    
    # Tips using jointOrient and changing shape's parent
    c03= mc.circle(n="RotateA")[0];
    c04= mc.ls(mc.joint(n="RotateB"),sl=1,l=1)[0];
    nc= mc.circle();
    mc.parent(mc.listRelatives(nc,ad=0)[0],c04,s=1,r=1);
    mc.reorder((mc.listRelatives(c03,ad=0)[0]),back=1);
    mc.setAttr(c04+".jointOrientX",90);
    mc.setAttr(c04+".drawStyle",2);
    mc.delete(nc);
sample();


Sample code B:

import maya.cmds as mc;
class jointWithMultiShapeNodes:
    def pointPositions(self):
        pos=[
            [0,0,4],
            [1,0,2.9],
            [.25,0,2.9],
            [.25,0,-1],
            [-.25,0,-1],
            [-.25,0,2.9],
            [-1,0,2.9],
            [0,0,4]];
        return(pos);
    def createNurbsArrows(self):
        nCrv01= mc.curve(p=self.pointPositions(),d=1);
        nCrv02= mc.curve(p=self.pointPositions(),d=1);
        nCrv03= mc.curve(p=self.pointPositions(),d=1);
        mc.rotate(0,45,0,nCrv02+".cv[*]",r=1,p=[0,0,0],os=1,fo=1);
        mc.rotate(0,-45,0,nCrv03+".cv[*]",r=1,p=[0,0,0],os=1,fo=1);
        mc.move(1.5,0,0,nCrv02+".cv[*]",r=1);
        mc.move(-1.5,0,0,nCrv03+".cv[*]",r=1);
        return([nCrv01,nCrv02,nCrv03]);
    def controllers(self):
        arrows= self.createNurbsArrows();
        mc.select(cl=1);
        nCrvSh01= mc.ls(mc.listRelatives(arrows[0],ad=0,f=1),l=1)[0];
        nCrvSh02= mc.ls(mc.listRelatives(arrows[1],ad=0,f=1),l=1)[0];
        nCrvSh03= mc.ls(mc.listRelatives(arrows[2],ad=0,f=1),l=1)[0];
        jnt= mc.joint(n="sampleController");
        mc.setAttr(jnt+".drawStyle",2);
        mc.parent(nCrvSh01,jnt,s=1,r=1);
        mc.parent(nCrvSh02,jnt,s=1,r=1);
        mc.parent(nCrvSh03,jnt,s=1,r=1);
        mc.delete(arrows);
        mc.select(jnt);
jointWithMultiShapeNodes().controllers();


Hope you like it. ;)

Comments

Popular posts from this blog

HIK: Getting current character and current source.