from sgMaya import sgCmds, sgModel

sels = pymel.core.ls( sl=1 )
geo = sels[0]
ctl = sels[1]

for i in range( 2 ):
    bendCtl = sgCmds.makeController( sgModel.Controller.switchPoints, 1, makeParent=1, name= ctl.replace( 'Part', 'Bend%d' % i ) )
    pBendCtl = bendCtl.getParent()
    
    bendCtl.getShape().shape_ty.set( 0.5 )
    bendCtl.getShape().shape_rx.set( 90 )
    
    pBendCtl.setParent( ctl )
    sgCmds.setTransformDefault( pBendCtl )
    pBendCtl.r.set( 0, 90*i, 0 )
    bend1, handle1 = pymel.core.nonLinear( geo, type='bend' )
    handle1.setParent( bendCtl )
    sgCmds.setTransformDefault( handle1 )
    handle1.r.set( 0,0,90 )
    bend1.lowBound.set( 0 )
    sgCmds.addOptionAttribute( bendCtl )
    sgCmds.addAttr( bendCtl, ln='bend', k=1 )
    multNode = pymel.core.createNode( 'multDoubleLinear' )
    bendCtl.bend >> multNode.input1
    multNode.input2.set( 5 )
    multNode.output >> bend1.curvature
    handle1.v.set( 0 )
    
    sgCmds.addAttr( bendCtl, ln='lowBound', k=1, min=0, dv=1 )
    sgCmds.addAttr( bendCtl, ln='highBound', k=1, min=0, dv=1 )
from sgMaya import sgCmds, sgModel
import pymel.core

sels = pymel.core.ls( sl=1 )

moveCtls = []
for sel in sels:
    bb = pymel.core.exactWorldBoundingBox( sel.getShape() )
    xDist = bb[3]-bb[0]
    yDist = bb[4]-bb[1]
    zDist = bb[5]-bb[2]
    size = max( xDist, yDist, zDist )
    
    moveCtl = sgCmds.makeController( sgModel.Controller.pinPoints, size / 1.5, makeParent=1 )
    if xDist == size: moveCtl.getShape()
    moveCtl.rename( sel + '_move' )
    moveCtl.getParent().setParent( sel )
    sgCmds.setTransformDefault( moveCtl.getParent() )
    moveCtls.append( moveCtl )
pymel.core.select( moveCtls )
 firstCtl = pymel.core.ls( '_'.join( endCtl.split( '_' )[:-1] ) + '_0' )[0]
 pFirstCtl = firstCtl.getParent()
 base = pFirstCtl.getParent()
 pMainCtl.setParent( base )
 
 lookAtBase = pymel.core.createNode( 'transform', n= 'lookAtBase_' + firstCtl )
 pymel.core.xform( lookAtBase, ws=1, matrix= firstCtl.wm.get() )
 lookAtChild = sgCmds.makeLookAtChild( mainCtl, lookAtBase )
 lookAtChild.rename( 'lookAtChild_' + firstCtl )
 
 lookAtBase.setParent( base )
 pFirstCtl.setParent( lookAtChild )
 
 joints = sgCmds.createFkControlJoint( pFirstCtl )
 joints[0].v.set( 0 )
 
 mainCtlFriend = pymel.core.createNode( 'transform' )
 pMainCtl = mainCtl.getParent()
 mainCtlFriend.setParent( pMainCtl )
 
 sgCmds.setTransformDefault( mainCtlFriend )
 
 blendNode = sgCmds.createBlendTwoMatrixNode( mainCtlFriend, mainCtl, local=1 )
 dcmp = sgCmds.getDecomposeMatrix( blendNode.matrixSum )
 
 for joint in joints[1:]:
     dcmp.outputRotate >> joint.r
 
 sgCmds.addOptionAttribute( mainCtl )
 sgCmds.addAttr( mainCtl, ln='showDetail', min=0, max=1, at='long', cb=1 )
 mainCtl.attr( 'showDetail' ) >> pFirstCtl.v
Beispiel #4
0
from sgMaya import sgCmds, sgModel
import pymel.core

sels = pymel.core.ls(sl=1)

moveCtls = []
for sel in sels:
    bb = pymel.core.exactWorldBoundingBox(sel.getShape())
    xDist = bb[3] - bb[0]
    yDist = bb[4] - bb[1]
    zDist = bb[5] - bb[2]
    size = max(xDist, yDist, zDist)

    moveCtl = sgCmds.makeController(sgModel.Controller.pinPoints,
                                    size / 1.5,
                                    makeParent=1)
    if xDist == size: moveCtl.getShape()
    moveCtl.rename(sel + '_move')
    moveCtl.getParent().setParent(sel)
    sgCmds.setTransformDefault(moveCtl.getParent())
    moveCtls.append(moveCtl)
pymel.core.select(moveCtls)
Beispiel #5
0
sels = pymel.core.ls(sl=1)
geo = sels[0]
ctl = sels[1]

for i in range(2):
    bendCtl = sgCmds.makeController(sgModel.Controller.switchPoints,
                                    1,
                                    makeParent=1,
                                    name=ctl.replace('Part', 'Bend%d' % i))
    pBendCtl = bendCtl.getParent()

    bendCtl.getShape().shape_ty.set(0.5)
    bendCtl.getShape().shape_rx.set(90)

    pBendCtl.setParent(ctl)
    sgCmds.setTransformDefault(pBendCtl)
    pBendCtl.r.set(0, 90 * i, 0)
    bend1, handle1 = pymel.core.nonLinear(geo, type='bend')
    handle1.setParent(bendCtl)
    sgCmds.setTransformDefault(handle1)
    handle1.r.set(0, 0, 90)
    bend1.lowBound.set(0)
    sgCmds.addOptionAttribute(bendCtl)
    sgCmds.addAttr(bendCtl, ln='bend', k=1)
    multNode = pymel.core.createNode('multDoubleLinear')
    bendCtl.bend >> multNode.input1
    multNode.input2.set(5)
    multNode.output >> bend1.curvature
    handle1.v.set(0)

    sgCmds.addAttr(bendCtl, ln='lowBound', k=1, min=0, dv=1)
Beispiel #6
0
def setLocatorForAram(mocGrp, grpName='MOCJNT_grp'):

    if grpName:
        ns = mocGrp.replace(grpName, '')
    else:
        ns = ':'.join(mocGrp.split(':')[:-1])
    sgCmds.createRetargetLocator(mocGrp)

    MOCJNT_ballEnd_L_ = pymel.core.ls(ns + 'MOCJNT_ballEnd_L_')[0]
    MOCJNT_ankle_L__rtLock_offset = pymel.core.ls(
        ns + 'MOCJNT_ankle_L__rtLock_offset')[0]

    MOCJNT_ballEnd_R_ = pymel.core.ls(ns + 'MOCJNT_ballEnd_R_')[0]
    MOCJNT_ankle_R__rtLock_offset = pymel.core.ls(
        ns + 'MOCJNT_ankle_R__rtLock_offset')[0]

    MOCJNT_ankle_L__rtLock_offset.setParent(MOCJNT_ballEnd_L_)
    MOCJNT_ankle_R__rtLock_offset.setParent(MOCJNT_ballEnd_R_)

    sgCmds.setRotateDefault(MOCJNT_ankle_L__rtLock_offset)
    sgCmds.setRotateDefault(MOCJNT_ankle_R__rtLock_offset)

    MOCJNT_ankle_R__rtLock_offset.attr('rotateZ').set(180)

    MOCJNT_hip_L_ = pymel.core.ls(ns + 'MOCJNT_hip_L_')[0]
    MOCJNT_knee_L_ = pymel.core.ls(ns + 'MOCJNT_knee_L_')[0]
    MOCJNT_knee_L__rtLock_offset = pymel.core.ls(
        ns + 'MOCJNT_knee_L__rtLock_offset')[0]
    MOCJNT_knee_L__rtLock = pymel.core.ls(ns + 'MOCJNT_knee_L__rtLock')[0]

    sgCmds.blendTwoMatrixConnect(MOCJNT_hip_L_,
                                 MOCJNT_knee_L_,
                                 MOCJNT_knee_L__rtLock_offset,
                                 ct=0,
                                 cr=1,
                                 cs=0)
    MOCJNT_knee_L__rtLock.ty.set(2)
    MOCJNT_knee_L__rtLock.getShape().attr('localScale').set(0.3, 0.3, 0.3)

    MOCJNT_hip_R_ = pymel.core.ls(ns + 'MOCJNT_hip_R_')[0]
    pymel.core.select(MOCJNT_hip_R_)
    MOCJNT_hip_R_c = pymel.core.joint(n=ns + 'MOCJNT_hip_R_c')
    MOCJNT_hip_R_c.r.set(180, 0, -180)
    MOCJNT_knee_R_ = pymel.core.ls(ns + 'MOCJNT_knee_R_')[0]
    MOCJNT_knee_R__rtLock_offset = pymel.core.ls(
        ns + 'MOCJNT_knee_R__rtLock_offset')[0]
    MOCJNT_knee_R__rtLock = pymel.core.ls(ns + 'MOCJNT_knee_R__rtLock')[0]

    sgCmds.blendTwoMatrixConnect(MOCJNT_hip_R_c,
                                 MOCJNT_knee_R_,
                                 MOCJNT_knee_R__rtLock_offset,
                                 ct=0,
                                 cr=1)
    MOCJNT_knee_R__rtLock.ty.set(-2)
    MOCJNT_knee_R__rtLock.getShape().attr('localScale').set(0.3, 0.3, 0.3)

    MOCJNT_shoulder_L_ = pymel.core.ls(ns + 'MOCJNT_shoulder_L_')[0]
    MOCJNT_elbow_L_ = pymel.core.ls(ns + 'MOCJNT_elbow_L_')[0]
    MOCJNT_elbow_L__rtLock_offset = pymel.core.ls(
        ns + 'MOCJNT_elbow_L__rtLock_offset')[0]
    MOCJNT_elbow_L__rtLock = pymel.core.ls(ns + 'MOCJNT_elbow_L__rtLock')[0]

    sgCmds.blendTwoMatrixConnect(MOCJNT_shoulder_L_,
                                 MOCJNT_elbow_L_,
                                 MOCJNT_elbow_L__rtLock_offset,
                                 ct=0,
                                 cr=1)
    MOCJNT_elbow_L__rtLock.tz.set(-2)
    MOCJNT_elbow_L__rtLock.getShape().attr('localScale').set(0.3, 0.3, 0.3)

    MOCJNT_shoulder_R_ = pymel.core.ls(ns + 'MOCJNT_shoulder_R_')[0]
    pymel.core.select(MOCJNT_shoulder_R_)
    MOCJNT_shoulder_R_c = pymel.core.joint(n=ns + 'MOCJNT_shoulder_R_c')
    MOCJNT_shoulder_R_c.r.set(180, 0, -180)
    MOCJNT_elbow_R_ = pymel.core.ls(ns + 'MOCJNT_elbow_R_')[0]
    MOCJNT_elbow_R__rtLock_offset = pymel.core.ls(
        ns + 'MOCJNT_elbow_R__rtLock_offset')[0]
    MOCJNT_elbow_R__rtLock = pymel.core.ls(ns + 'MOCJNT_elbow_R__rtLock')[0]

    sgCmds.blendTwoMatrixConnect(MOCJNT_shoulder_R_c,
                                 MOCJNT_elbow_R_,
                                 MOCJNT_elbow_R__rtLock_offset,
                                 ct=0,
                                 cr=1,
                                 cs=0)
    MOCJNT_elbow_R__rtLock.tz.set(2)
    MOCJNT_elbow_R__rtLock.getShape().attr('localScale').set(0.3, 0.3, 0.3)

    MOCJNT_chest_rtLock_offset = pymel.core.ls(ns +
                                               'MOCJNT_chest_rtLock_offset')[0]
    MOCJNT_chest_rtLock_offset.r.set(180, 90, 90)

    MOCJNT_head_rtLock = pymel.core.ls(ns + 'MOCJNT_head_rtLock')[0]
    MOCJNT_head_rtLock.r.set(180, 90, 90)

    MOCJNT_wrist_R__rtLock = pymel.core.ls(ns + 'MOCJNT_wrist_R__rtLock')[0]
    MOCJNT_wrist_R__rtLock.r.set(180, 0, 0)

    MOCJNT_wrist_R__rtLock2 = pymel.core.spaceLocator(
        n=ns + 'MOCJNT_wrist_R__rtLock2')
    MOCJNT_wrist_R_ = pymel.core.ls(ns + 'MOCJNT_wrist_R_')[0]
    MOCJNT_wrist_R__rtLock2.setParent(MOCJNT_wrist_R_)
    sgCmds.setTransformDefault(MOCJNT_wrist_R__rtLock2)

    MOCJNT_shoulder_R__rtLock_offset = pymel.core.ls(
        ns + 'MOCJNT_shoulder_R__rtLock_offset')[0]
    MOCJNT_shoulder_R__rtLock_offset.r.set(180, 0, -180)

    MOCJNT_hip_R__rtLock = pymel.core.ls(ns + 'MOCJNT_hip_R__rtLock')[0]
    MOCJNT_hip_R__rtLock.r.set(0, 180, 0)

    MOCJNT_knee_L_ = pymel.core.ls(ns + 'MOCJNT_knee_L_')[0]
    MOCJNT_knee_L__rtLock2 = pymel.core.spaceLocator(
        n='MOCJNT_knee_L__rtLock2')
    MOCJNT_knee_L__rtLock2.setParent(MOCJNT_knee_L_)

    MOCJNT_knee_R_ = pymel.core.ls(ns + 'MOCJNT_knee_R_')[0]
    MOCJNT_knee_R__rtLock2 = pymel.core.spaceLocator(
        n='MOCJNT_knee_R__rtLock2')
    MOCJNT_knee_R__rtLock2.setParent(MOCJNT_knee_R_)

    MOCJNT_elbow_L__rtLock2 = pymel.core.spaceLocator(
        n=ns + 'MOCJNT_elbow_L__rtLock2')
    MOCJNT_elbow_L__rtLock2.setParent(MOCJNT_elbow_L_)
    sgCmds.setTransformDefault(MOCJNT_elbow_L__rtLock2)

    MOCJNT_elbow_R__rtLock2 = pymel.core.spaceLocator(
        n=ns + 'MOCJNT_elbow_R__rtLock2')
    MOCJNT_elbow_R__rtLock2.setParent(MOCJNT_elbow_R_)
    sgCmds.setTransformDefault(MOCJNT_elbow_R__rtLock2)
Beispiel #7
0
def connectMocForPipi(mocGrp,
                      rigGrp,
                      mocGrpName='MOCJNT_grp',
                      pipiGrpName='CH_Pipi'):

    if mocGrpName:
        mocns = mocGrp.replace(mocGrpName, '')
    else:
        mocns = ':'.join(mocGrp.split(':')[:-1])

    if pipiGrpName:
        rigns = rigGrp.replace(pipiGrpName, '')
    else:
        rigns = ':'.join(rigGrp.split(':')[:-1])

    setLocatorForPipi(mocGrp, mocGrpName)

    Move_Ctrl = pymel.core.ls(rigns + 'Move_Ctrl')[0]
    MOCJNT_grp = pymel.core.ls(mocns + 'MOCJNT_grp')[0]

    retargetRotateSrcList = [
        'MOCJNT_spines_0_rtLock', 'MOCJNT_spines_1_rtLock',
        'MOCJNT_chest_rtLock', 'MOCJNT_head_rtLock',
        'MOCJNT_clevicle_L__rtLock', 'MOCJNT_clevicle_R__rtLock'
    ]
    retargetRotateTrgList = [
        'SpineFk1_Ctrl', 'SpineFk2_Ctrl', 'Chest_Ctrl', 'Head_Ctrl',
        'LfClavicle_Ctrl', 'RtClavicle_Ctrl'
    ]

    for i in range(len(retargetRotateSrcList)):
        MOCJNT = pymel.core.ls(mocns + retargetRotateSrcList[i])[0]
        CTL = pymel.core.ls(rigns + retargetRotateTrgList[i])[0]
        retargetRotate(MOCJNT, MOCJNT_grp, CTL, Move_Ctrl)

    retargetPointSrcList = [
        'MOCJNT_elbow_L__rtLock', 'MOCJNT_elbow_R__rtLock',
        'MOCJNT_knee_L__rtLock', 'MOCJNT_knee_R__rtLock'
    ]
    retargetPointTrgList = [
        'LfArmPv_Ctrl', 'RtArmPv_Ctrl', 'LfLegPv_Ctrl', 'RtLegPv_Ctrl'
    ]

    for i in range(len(retargetPointSrcList)):
        MOCJNT = pymel.core.ls(mocns + retargetPointSrcList[i])[0]
        CTL = pymel.core.ls(rigns + retargetPointTrgList[i])[0]
        retargetPoint(MOCJNT, MOCJNT_grp, CTL, Move_Ctrl)

    MOCJNT_ball_L_rz = pymel.core.ls(mocns + 'MOCJNT_ball_L_.rz')[0]
    MOCJNT_ball_R_rz = pymel.core.ls(mocns + 'MOCJNT_ball_R_.rz')[0]
    LfLegIk_Ctrl_footRoll = pymel.core.ls(rigns + 'LfLegIk_Ctrl.FootRoll')[0]
    RtLegIk_Ctrl_footRoll = pymel.core.ls(rigns + 'RtLegIk_Ctrl.FootRoll')[0]

    multNode_forBall_L_ = pymel.core.createNode('multDoubleLinear')
    multNode_forBall_L_.input2.set(0.1111)
    multNode_forBall_R_ = pymel.core.createNode('multDoubleLinear')
    multNode_forBall_R_.input2.set(0.1111)
    MOCJNT_ball_L_rz >> multNode_forBall_L_.input1
    MOCJNT_ball_R_rz >> multNode_forBall_R_.input1

    multNode_forBall_L_.output >> LfLegIk_Ctrl_footRoll
    multNode_forBall_R_.output >> RtLegIk_Ctrl_footRoll

    #---------------------------------------------------------------

    retargetParentSrcList = [
        'MOCJNT_root_rtLock', 'MOCJNT_ankle_L__rtLock',
        'MOCJNT_ankle_R__rtLock'
    ]
    retargetParentTrgList = ['Root_Ctrl', 'LfLegIk_Ctrl', 'RtLegIk_Ctrl']

    Move_Ctrl_child = pymel.core.createNode('transform',
                                            n=Move_Ctrl + '_offset')
    Move_Ctrl_child.setParent(Move_Ctrl)
    Move_Ctrl_child.t.set(0, 0, 0)
    Move_Ctrl_child.r.set(0, 0, 0)
    Move_Ctrl_child.s.set(1.1, 1, 1.1)

    for i in range(len(retargetParentSrcList)):
        MOCJNT = pymel.core.ls(mocns + retargetParentSrcList[i])[0]
        CTL = pymel.core.ls(rigns + retargetParentTrgList[i])[0]
        retargetParent(MOCJNT, MOCJNT_grp, CTL, Move_Ctrl_child)
        if i == 0: continue
        CTL.attr('PvCtrlVisibility').set(1)

    #---------------------------------------------------------------

    def setTransformDefault(inputTarget):
        target = pymel.core.ls(inputTarget)[0]
        attrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']
        values = [0, 0, 0, 0, 0, 0, 1, 1, 1]
        for i in range(len(attrs)):
            try:
                cmds.setAttr(target + '.' + attrs[i], values[i])
            except:
                pass

    retargetShoulder_L_ = pymel.core.createNode('transform',
                                                n=rigns +
                                                'RootObj_Shoulder_L_')
    retargetShoulder_R_ = pymel.core.createNode('transform',
                                                n=rigns +
                                                'RootObj_Shoulder_R_')
    retargetShoulder_L_.setParent(rigns + 'LfClavicle_Ctrl')
    retargetShoulder_L_.dh.set(1)
    retargetShoulder_R_.setParent(rigns + 'RtClavicle_Ctrl')
    retargetShoulder_R_.dh.set(1)
    setTransformDefault(retargetShoulder_L_)
    retargetShoulder_L_.tx.set(1.09)
    setTransformDefault(retargetShoulder_R_)
    retargetShoulder_R_.tx.set(-1.09)
    retargetShoulder_L_.s.set(1.54, 1.54, 1.54)
    retargetShoulder_R_.s.set(1.54, 1.54, 1.54)

    retargetRotateSrcList = [
        'MOCJNT_shoulder_L__rtLock', 'MOCJNT_shoulder_R__rtLock'
    ]
    retargetRotateTrgList = ['RootObj_Shoulder_L_', 'RootObj_Shoulder_R_']

    for i in range(len(retargetRotateSrcList)):
        MOCJNT = pymel.core.ls(mocns + retargetRotateSrcList[i])[0]
        CTL = pymel.core.ls(rigns + retargetRotateTrgList[i])[0]
        retargetRotate(MOCJNT, MOCJNT_grp, CTL, Move_Ctrl)

    retargetParentSrcList = [[
        'MOCJNT_wrist_L__rtLock', 'MOCJNT_shoulder_L__rtLock'
    ], ['MOCJNT_wrist_R__rtLock', 'MOCJNT_shoulder_R__rtLock']]
    retargetParentTrgList = [['LfArmIk_Ctrl', 'RootObj_Shoulder_L_'],
                             ['RtArmIk_Ctrl', 'RootObj_Shoulder_R_']]

    for i in range(len(retargetParentSrcList)):
        MOCJNT = pymel.core.ls(mocns + retargetParentSrcList[i][0])[0]
        CTL = pymel.core.ls(rigns + retargetParentTrgList[i][0])[0]
        MOCJNT_base = pymel.core.ls(mocns + retargetParentSrcList[i][1])[0]
        CTL_base = pymel.core.ls(rigns + retargetParentTrgList[i][1])[0]
        retargetParent(MOCJNT, MOCJNT_base, CTL, CTL_base)
        CTL.attr('PvCtrlVisibility').set(1)

    mocloc_L_list = [
        'MOCJNT_wrist_L__rtLock2', 'MOCJNT_elbow_L__rtLock2',
        'MOCJNT_shoulder_L__rtLock2', 'MOCJNT_clevicle_L__rtLock'
    ]
    ctl_L_list = [
        'LfArm3Fk_Ctrl', 'LfArm2Fk_Ctrl', 'LfArm1Fk_Ctrl', 'LfClavicle_Ctrl'
    ]

    for i in range(len(mocloc_L_list) - 1):
        MOCJNT = pymel.core.ls(mocns + mocloc_L_list[i])[0]
        MOCJNT_P = pymel.core.ls(mocns + mocloc_L_list[i + 1])[0]
        CTL = pymel.core.ls(rigns + ctl_L_list[i])[0]
        CTL_P = pymel.core.ls(rigns + ctl_L_list[i + 1])[0]
        retargetRotate(MOCJNT, MOCJNT_P, CTL, CTL_P)

    mocloc_R_list = [
        'MOCJNT_wrist_R__rtLock2', 'MOCJNT_elbow_R__rtLock2',
        'MOCJNT_shoulder_R__rtLock2', 'MOCJNT_clevicle_R__rtLock'
    ]
    ctl_R_list = [
        'RtArm3Fk_Ctrl', 'RtArm2Fk_Ctrl', 'RtArm1Fk_Ctrl', 'RtClavicle_Ctrl'
    ]

    for i in range(len(mocloc_L_list) - 1):
        MOCJNT = pymel.core.ls(mocns + mocloc_R_list[i])[0]
        MOCJNT_P = pymel.core.ls(mocns + mocloc_R_list[i + 1])[0]
        CTL = pymel.core.ls(rigns + ctl_R_list[i])[0]
        CTL_P = pymel.core.ls(rigns + ctl_R_list[i + 1])[0]
        retargetRotate(MOCJNT, MOCJNT_P, CTL, CTL_P)
multNodeValue = [0,0,0]
multNodeValue[ dirIndex%3 ] = 0.25

trChild = pymel.core.createNode( 'transform' )
trParent = pymel.core.createNode( 'transform' )
trChild.rename( 'trChild' )
trParent.rename( 'trParent' )

multNodeChild = pymel.core.createNode( 'multiplyDivide' )
multNodeParent = pymel.core.createNode( 'multiplyDivide' )

dcmpChild.ot >> multNodeChild.input1; multNodeChild.input2.set( multNodeValue )
dcmpParent.ot >> multNodeParent.input1; multNodeParent.input2.set( multNodeValue )

multNodeChild.output >> trChild.t
multNodeParent.output >> trParent.t

trChild.dh.set( 1 )
trParent.dh.set( 1 )
trChildG = pymel.core.group( em=1 )
trParentG = pymel.core.group( em=1 )
trChild.setParent( trChildG )
trParent.setParent( trParentG )

pymel.core.parent( trChildG, sels[1] )
pymel.core.parent( trParentG, sels[0] )

sgCmds.setTransformDefault( trChildG )
sgCmds.setTransformDefault( trParentG )
sels[1].s >> trChildG.s
sels[0].s >> trParentG.s
    base = pFirstCtl.getParent()
    pMainCtl.setParent(base)

    lookAtBase = pymel.core.createNode('transform', n='lookAtBase_' + firstCtl)
    pymel.core.xform(lookAtBase, ws=1, matrix=firstCtl.wm.get())
    lookAtChild = sgCmds.makeLookAtChild(mainCtl, lookAtBase)
    lookAtChild.rename('lookAtChild_' + firstCtl)

    lookAtBase.setParent(base)
    pFirstCtl.setParent(lookAtChild)

    joints = sgCmds.createFkControlJoint(pFirstCtl)
    joints[0].v.set(0)

    mainCtlFriend = pymel.core.createNode('transform')
    pMainCtl = mainCtl.getParent()
    mainCtlFriend.setParent(pMainCtl)

    sgCmds.setTransformDefault(mainCtlFriend)

    blendNode = sgCmds.createBlendTwoMatrixNode(mainCtlFriend,
                                                mainCtl,
                                                local=1)
    dcmp = sgCmds.getDecomposeMatrix(blendNode.matrixSum)

    for joint in joints[1:]:
        dcmp.outputRotate >> joint.r

    sgCmds.addOptionAttribute(mainCtl)
    sgCmds.addAttr(mainCtl, ln='showDetail', min=0, max=1, at='long', cb=1)
    mainCtl.attr('showDetail') >> pFirstCtl.v