Beispiel #1
0
def Box(name='box_cnt', group=False, size=1.0):
    ''' Creates a box shape.
        If group is True, will group control and
        return a list [group,control].
    '''

    #creating the curve
    curve = cmds.curve(d=1,
                       p=[(1, 1, -1), (1, 1, 1), (1, -1, 1), (1, -1, -1),
                          (1, 1, -1), (-1, 1, -1), (-1, -1, -1), (-1, -1, 1),
                          (-1, 1, 1), (1, 1, 1), (1, -1, 1), (-1, -1, 1),
                          (-1, -1, -1), (1, -1, -1), (1, 1, -1), (-1, 1, -1),
                          (-1, 1, 1), (1, 1, 1), (1, 1, -1)])

    #naming control
    node = cmds.rename(curve, name)

    #sizing
    cmds.scale(size, size, size, node)
    cmds.FreezeTransformations(node)

    #grouping control
    if group == True:
        grp = cmds.group(node, n=name + '_grp')

        return [grp, node]

    #return
    return node
Beispiel #2
0
def Circle(name='circle_cnt', group=False, size=1.0):
    ''' Creates a circle shape.
        If group is True, will group control and
        return a list [group,control].
    '''

    #creating the curve
    curve = cmds.circle(radius=1, constructionHistory=False)

    #transform to standard
    cmds.rotate(0, 90, 0, curve)

    cmds.makeIdentity(curve, apply=True, t=1, r=1, s=1, n=0)

    #naming control
    node = cmds.rename(curve, name)

    #sizing
    cmds.scale(size, size, size, node)
    cmds.FreezeTransformations(node)

    #grouping control
    if group == True:
        grp = cmds.group(node, n=name + '_grp')

        return [grp, node]

    #return
    return node
Beispiel #3
0
def Pin(name='pin_cnt', group=False, size=1.0):
    ''' Creates a pin shape.
        If group is True, will group control and
        return a list [group,control].
    '''

    #creating the curve
    curve = cmds.curve(d=1,
                       p=[(0, 0, 0), (0, 1.2, 0), (-0.235114, 1.276393, 0),
                          (-0.380423, 1.476393, 0), (-0.380423, 1.723607, 0),
                          (-0.235114, 1.923607, 0), (0, 2, 0),
                          (0.235114, 1.923607, 0), (0.380423, 1.723607, 0),
                          (0.380423, 1.476393, 0), (0.235114, 1.276393, 0),
                          (0, 1.2, 0)])
    #transform to standard
    cmds.rotate(0, -90, 0, curve)

    cmds.makeIdentity(curve, apply=True, t=1, r=1, s=1, n=0)

    #naming control
    node = cmds.rename(curve, name)

    #sizing
    cmds.scale(size, size, size, node)
    cmds.FreezeTransformations(node)

    #grouping control
    if group == True:
        grp = cmds.group(node, n=name + '_grp')

        return [grp, node]

    #return
    return node
Beispiel #4
0
def implicitSphere(name, group=False, size=1.0):
    ''' Creates a square shape.
        If group is True, will group control and
        return a list [group,control].
    '''

    #creating the curve
    curve = cmds.createNode('implicitSphere')
    curve = cmds.listRelatives(curve, parent=True)[0]

    #setup curve
    cmds.makeIdentity(curve, apply=True, t=1, r=1, s=1, n=0)

    #naming control
    node = cmds.rename(curve, name)

    #sizing
    cmds.scale(size, size, size, node)
    cmds.FreezeTransformations(node)

    #grouping control
    if group == True:
        grp = cmds.group(node, n=name + '_grp')

        return [grp, node]

    #return
    return node
Beispiel #5
0
def createCubeController():
    """This function creates a controller to drive the clusters"""

    # Create list of clusters
    clusterList = addClusters()
    
    for clusterName in clusterList:
        cubeCtrl = cmds.curve(n="clusterCtrl",
                   degree=1,
                   point=[(-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5),
                          (-0.5, -0.5, 0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (-0.5, -0.5, 0.5),
                          (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5),
                          (-0.5, 0.5, -0.5)],
                   k=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0])
    
        #clusterName = "cluster%iHandle"%(i+1)
        cmds.select(cubeCtrl, clusterName)
        cmds.MatchTransform()
        cmds.select(cubeCtrl, r=True)
        cmds.FreezeTransformations()
        cmds.select(cubeCtrl, clusterName)
        cmds.parentConstraint(mo=True, w=1)
        
    cmds.select("clusterCtrl*")
    cmds.group(name="ClusterControlGroup")

    cmds.select("cluster*Handle")
    handleGroup = cmds.group(name="ClusterHandlesGroup")
    cmds.setAttr("TreadCurve.visibility",0)
    cmds.setAttr("%s.visibility"%handleGroup,0)
Beispiel #6
0
def Square(name='square_cnt', group=False, size=1.0):
    ''' Creates a square shape.
        If group is True, will group control and
        return a list [group,control].
    '''

    #creating the curve
    curve = cmds.curve(d=1,
                       p=[(0, 1, 1), (0, 1, -1), (0, -1, -1), (0, -1, 1),
                          (0, 1, 1)])

    #setup curve
    cmds.makeIdentity(curve, apply=True, t=1, r=1, s=1, n=0)

    #naming control
    node = cmds.rename(curve, name)

    #sizing
    cmds.scale(size, size, size, node)
    cmds.FreezeTransformations(node)

    #grouping control
    if group == True:
        grp = cmds.group(node, n=name + '_grp')

        return [grp, node]

    #return
    return node
Beispiel #7
0
def Freeze(*args):

    sl = mc.ls(sl=True)

    for i in range(len(sl)):
        mc.select(sl[i])

        mc.delete(ch=True)

        #Freeze Transformation
        mc.FreezeTransformations()
def setNurbsTxt(*args):#romain truchard 2017
  
  #1-create text---

  fontName = cmds.optionMenu(fontOptionMenu, q=True, value=True)#query selected font

  nameFormat = ("\"" + fontName + "\"")#add quotation marks to selected font

  nurbsTextFieldValue = cmds.textField(nurbsTextField, query=True, text=True)#get user input

  tempCurveTxt = cmds.textCurves(font=nameFormat, text=nurbsTextFieldValue, name="txtTemp")#create textCurves with correct font

  #2-merge the curves---

  cmds.select(r=True, hi=True)#select everything : transform shpes etc

  curSel = cmds.ls(sl=True) #put everything in array

  shapes = cmds.ls(curSel, shapes=True)#put all shapes in array

  transforms = cmds.ls(curSel, transforms=True)#put all transforms in array

  tempGrp = cmds.group(em=True, n="grpTemp")#create empty group to put all shapes

  cmds.select(transforms)#select all transforms

  cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)

  cmds.select(shapes)#select all shapes

  cmds.select(tempGrp, add=True)#add empty group to selection

  cmds.parent(r=True, s=True)#parent -r -s (merge curves in empty group)

  finalText = cmds.rename("grpTemp", nurbsTextFieldValue)#rename group with user input

  cmds.select(transforms[0])#select remaining transforms

  cmds.delete()#delete them

  cmds.select(finalText)

  boundingBox = cmds.xform(finalText, query=True, bb=True)

  halfOfXboundingBox = boundingBox[3] / 2

  cmds.xform(finalText, ws=True, piv=[halfOfXboundingBox, 0, 0])

  worldPosition = cmds.xform(finalText, q=True, piv=True, ws=True)

  cmds.xform(finalText, translation=(-worldPosition[0],-worldPosition[1],-worldPosition[2]))

  cmds.FreezeTransformations(finalText)
def orientJoints():
    bf_int = cmds.intField(basefinger, q=True, v=True)
    
    for x in range(1, bf_int+1):
        cmds.select("L_finger_"+str(x)+"_1")
        cmds.FreezeTransformations()
        if x == 1:
            cmds.joint(e=True, oj="xzy", sao="zup", ch=True, zso=True)
        else:
            cmds.joint(e=True, oj="xyz", sao="zdown", ch=True, zso=True)
        cmds.makeIdentity("L_Hand", a=True, r=True)
        cmds.DeleteHistory("L_Hand")
Beispiel #10
0
def radialInstance(*args):
    nodes = cmds.ls(sl=True)
    cmds.FreezeTransformations()
    number = cmds.textField("number", q=True, tx=True)
    number = int(number)
    angle = 360.0 / number
    angleRotate = 360.0 / number
    radioSelect = cmds.radioCollection('rcName', q=True, select=True)
    for i in range(number - 1):
        ins = cmds.instance(nodes)
        cmds.setAttr(ins[0] + ".rotate" + radioSelect, angle)
        angle += angleRotate
Beispiel #11
0
def GEO_freeze_transformations():
    ''' freezes transformations of selection  '''
    sel = cmds.ls(sl=True)
    if cmds.nodeType(sel) == "mesh":
        all_sel = cmds.listRelatives(sel, parent=True, fullPath=False)

    if all_sel is None:
        return "Select Meshes first.", 0

    for each in all_sel:
        cmds.FreezeTransformations(each)
    return "Transformations freezed on ({}) transform nodes".format(
        len(all_sel)), 1
Beispiel #12
0
def Sphere(name='sphere_cnt', group=False, size=1.0):
    ''' Creates a sphere shape.
        If group is True, will group control and
        return a list [group,control].
    '''

    #creating the curve
    curve = cmds.curve(d=1,
                       p=[(0, 1, 0), (-0.382683, 0.92388, 0),
                          (-0.707107, 0.707107, 0), (-0.92388, 0.382683, 0),
                          (-1, 0, 0), (-0.92388, -0.382683, 0),
                          (-0.707107, -0.707107, 0), (-0.382683, -0.92388, 0),
                          (0, -1, 0), (0.382683, -0.92388, 0),
                          (0.707107, -0.707107, 0), (0.92388, -0.382683, 0),
                          (1, 0, 0), (0.92388, 0.382683, 0),
                          (0.707107, 0.707107, 0), (0.382683, 0.92388, 0),
                          (0, 1, 0), (0, 0.92388, 0.382683),
                          (0, 0.707107, 0.707107), (0, 0.382683, 0.92388),
                          (0, 0, 1), (0, -0.382683, 0.92388),
                          (0, -0.707107, 0.707107), (0, -0.92388, 0.382683),
                          (0, -1, 0), (0, -0.92388, -0.382683),
                          (0, -0.707107, -0.707107), (0, -0.382683, -0.92388),
                          (0, 0, -1), (0, 0.382683, -0.92388),
                          (0, 0.707107, -0.707107), (0, 0.92388, -0.382683),
                          (0, 1, 0), (-0.382683, 0.92388, 0),
                          (-0.707107, 0.707107, 0), (-0.92388, 0.382683, 0),
                          (-1, 0, 0), (-0.92388, 0, 0.382683),
                          (-0.707107, 0, 0.707107), (-0.382683, 0, 0.92388),
                          (0, 0, 1), (0.382683, 0, 0.92388),
                          (0.707107, 0, 0.707107), (0.92388, 0, 0.382683),
                          (1, 0, 0), (0.92388, 0, -0.382683),
                          (0.707107, 0, -0.707107), (0.382683, 0, -0.92388),
                          (0, 0, -1), (-0.382683, 0, -0.92388),
                          (-0.707107, 0, -0.707107), (-0.92388, 0, -0.382683),
                          (-1, 0, 0)])

    #naming control
    node = cmds.rename(curve, name)

    #sizing
    cmds.scale(size, size, size, node)
    cmds.FreezeTransformations(node)

    #grouping control
    if group == True:
        grp = cmds.group(node, n=name + '_grp')

        return [grp, node]

    #return
    return node
Beispiel #13
0
def fixLocalRotation(*arg):
    unParentJoints()
    currentSide = ["lf", "rg"]

    if (jointsMirrored):
        for i in range(0, 2):

            selectAllBones()
            cmds.FreezeTransformations()
            cmds.select("root")
            #per tutorial - secondary axis of rotation is set to X no default Y
            cmds.joint(e=True,
                       oj='xzy',
                       secondaryAxisOrient='xup',
                       ch=True,
                       zso=True)
            cmds.select(currentSide[i] + "_arm_1")
            cmds.joint(e=True,
                       oj='xzy',
                       secondaryAxisOrient='xup',
                       ch=True,
                       zso=True)
            cmds.select(currentSide[i] + "_thigh")
            cmds.joint(e=True,
                       oj='xzy',
                       secondaryAxisOrient='xup',
                       ch=True,
                       zso=True)
            cmds.select(currentSide[i] + "_thumb_1")
            cmds.joint(e=True,
                       oj='xzy',
                       secondaryAxisOrient='xup',
                       ch=True,
                       zso=True)
            #parents the finger joints
            for n in range(0, numOfFingers):
                cmds.select(currentSide[i] + "_" + currentFinger[n] +
                            "_finger_1")
                cmds.joint(e=True,
                           oj='xzy',
                           secondaryAxisOrient='xup',
                           ch=True,
                           zso=True)
    else:
        print("Joints must be mirrored")

    cmds.select(cl=True)
    ParentJoints()
def petal(core=None, xyz=[0, 0, 0], rot=[0, 0, 0]):

    myname = "petalObj"
    if core:
        myname = "flowerPetalObj"

    # build the petal, position it
    UNUSED = cmds.sphere(name=myname, axis=[0, 1, 0])
    if core:
        cmds.move(0, 0, -1.6)
    else:
        cmds.move(*xyz)  # unpack xyz

    cmds.scale(0.7, 0.3, 1.7)

    if core:
        cmds.FreezeTransformations()
        cmds.ResetTransformations()

    p = cmds.ls(sl=True)[0]

    if core:
        cmds.parent(p, core)

    cmds.select(p)
    cmds.pickWalk(direction="down")
    myPetalShape = cmds.ls(sl=True)

    # move the tip of the petal
    cmds.select(p + ".cv[3][7]")
    cmds.move(0, 2, 0, relative=True)

    # Select the inner part of the petal pull down
    # One loop for the U direction
    for uCV in xrange(5, 7):  # These numbers are
        for vCV in xrange(0, 8):  # not arbitrary.
            suffix = ".cv[%i][%i]" % (uCV, vCV)
            cmds.select(p + suffix)
            cmds.move(0, -0.4, 0, relative=True)

    if rot:
        cmds.select(p)
        cmds.rotate(*rot, relative=False)

    return p
Beispiel #15
0
def controlOnLocator(controllerName="controller", *args):
    """This function adds controllers on the selected locators
    
    Parameters
    ----------
    controllerName : str
        The desired naming convention for the controllers and their group

    
    Returns
    -------
    list
        A list containing the driven group on index [0] and controller group on index [1]
    """

    controllerList = []

    for locator in args:
        # Create a curve with a cube shape
        cubeCtrl = cmds.curve(n=controllerName,
                   degree=1,
                   point=[(-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5),
                          (-0.5, -0.5, 0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (-0.5, -0.5, 0.5),
                          (0.5, -0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5),
                          (-0.5, 0.5, -0.5)],
                   k=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0])

        controllerList.append(cubeCtrl)

        # Select both objects to match translation
        cmds.select(cubeCtrl, locator)
        cmds.MatchTranslation()
        cmds.select(cubeCtrl, r=True)
        cmds.FreezeTransformations()
        cmds.select(cubeCtrl, locator)
        cmds.parentConstraint(mo=True, w=1)

    cmds.select(args)
    locatorsGroup = cmds.group(name="PointLocatorsGroup")
    cmds.setAttr("{}.visibility".format(locatorsGroup), 0)

    cmds.select(controllerList)
    controllerGroup = cmds.group(name="{}Group".format(controllerName))

    return [locatorsGroup, controllerGroup]
Beispiel #16
0
def FourWay(name='fourway_cnt', group=False, size=1.0):
    ''' Creates a four leg arrow shape.
        If group is True, will group control and
        return a list [group,control].
    '''

    #creating the curve
    curve = cmds.curve(d=1,
                       p=[(-4, 0, 0), (-2, 0, -1.5), (-2, 0, -0.5),
                          (-0.5, 0, -0.5), (-0.5, 0, -2), (-1.5, 0, -2),
                          (0, 0, -4), (1.5, 0, -2),
                          (0.5, 0, -2), (0.5, 0, -0.5), (2, 0, -0.5),
                          (2, 0, -1.5), (4, 0, 0), (2, 0, 1.5), (2, 0, 0.5),
                          (0.5, 0, 0.5), (0.5, 0, 2), (1.5, 0, 2), (0, 0, 4),
                          (-1.5, 0, 2), (-0.5, 0, 2), (-0.5, 0, 0.5),
                          (-2, 0, 0.5), (-2, 0, 1.5), (-4, 0, 0)])

    #resize to standard
    cmds.scale(0.25, 0.25, 0.25, curve)
    cmds.rotate(0, 0, 90, curve)

    cmds.makeIdentity(curve, apply=True, t=1, r=1, s=1, n=0)

    #naming control
    node = cmds.rename(curve, name)

    #sizing
    cmds.scale(size, size, size, node)
    cmds.FreezeTransformations(node)

    #grouping control
    if group == True:
        grp = cmds.group(node, n=name + '_grp')

        return [grp, node]

    #return
    return node
Beispiel #17
0
def makeTread(*args):
    """This function creates the circle that represent the tread"""

    # Get the position from both locators
    loc1Pos = cmds.getAttr("{}.translateZ".format(data.firstLocator))
    loc2Pos = cmds.getAttr("{}.translateZ".format(data.secondLocator))
    locDistance = abs(loc1Pos-loc2Pos)
    data.curveRadius = locDistance/2.0
    locCenter = (loc1Pos+loc2Pos)/2.0
    
    # Create the curve
    curveQuality = cmds.intSliderGrp("curveQuality", q=True, v=True)
    data.treadCircle = cmds.circle(name="TreadCurve", radius=data.curveRadius, nr=(1,0,0), sections=curveQuality)[0]
    data.treadCircle = checkDuplicatedName(data.treadCircle)
    
    # ****************************************** Here we align the circle to the locators ********************************************
    
    # Create a group containing the locators
    locatorGroup = cmds.group(data.firstLocator, data.secondLocator, n="LocGroup")

    # Select the circle
    cmds.select(data.treadCircle)

    # Select the group
    cmds.select(locatorGroup, add=True)

    # Align the circle to the group
    cmds.align(x="mid", y="mid", z="mid", alignToLead=True)

    # Unparent the locators
    cmds.parent(data.firstLocator, data.secondLocator, world=True)
    # Delete the locator group
    cmds.delete(locatorGroup)
    
    # Finish selecting the curve
    cmds.select(data.treadCircle)
    cmds.FreezeTransformations()
    cmds.DeleteHistory()
    def jointsSetup(self):
        self.all_locs = []
        self.all_joint = []
        for each in self.all_guide:
            _joint = pm.joint(n=each.name().replace('guide', 'jnt__'))
            _loc = pm.spaceLocator(n=each.name().replace('guide', 'loc__'))
            pm.PyNode(_loc).getShape().localScaleX.set(0.2)
            pm.PyNode(_loc).getShape().localScaleY.set(0.2)
            pm.PyNode(_loc).getShape().localScaleZ.set(0.2)
            adb.changeColor_func(_loc, 'index', 14)
            pm.parent(_joint, w=True)
            self.all_joint.append(_joint)
            self.all_locs.append(_loc)

        for joint, guide in zip(self.all_joint, self.all_guide):
            pm.matchTransform(joint, guide, pos=True)
            pm.parent(joint, guide)

        for loc, guide in zip(self.all_locs, self.all_guide):
            pm.matchTransform(loc, guide, pos=True)
            pm.parentConstraint(guide, loc)
        pm.select(None)

        ## SCALING
        scaling_grp = pm.group(em=True, n='scaling__grp__')
        pm.parent('l__arm_clav__guide__root__grp__',
                  'l__arm_elbow__guide__root__grp__',
                  'l__arm_hand__guide__root__grp__',
                  'l__leg_main__guide__root__grp__',
                  'r__arm_clav__guide__root__grp__',
                  'r__arm_elbow__guide__root__grp__',
                  'r__arm_hand__guide__root__grp__',
                  'r__leg_main__guide__root__grp__', 'spine_guide__curve',
                  scaling_grp)
        pm.PyNode(scaling_grp).setScale((0.05, 0.05, 0.05))
        pm.parent(w=True)
        pm.delete(scaling_grp)
        ## -----------------------------------------------

        ## SPINE SUITE
        pm.select(self.spine_curve, r=True)
        sel = pm.select(".cv[*]")
        cvs = pm.filterExpand(fullPath=True, sm=28)
        # Nombre de vertex sur la curve #
        nbCvs = len(cvs)
        oCollClusters = [pm.cluster(cvs[x]) for x in range(0, nbCvs)]

        self.all_spine_guide = []
        for clus in oCollClusters:
            clus[1].v.set(0)
            spine_guide = pm.sphere(n='m__spine__guide_01', r=0.05)[0]
            self.all_spine_guide.append(spine_guide)
            pm.matchTransform(spine_guide, clus, pos=True)

        for oClus, spine in zip(oCollClusters, self.all_spine_guide):
            pm.parentConstraint(spine, oClus)

        for spine_guide in self.all_spine_guide:
            pm.select(spine_guide)
            mc.FreezeTransformations()

        pm.PyNode(self.all_spine_guide[1]).v.set(0)
        pm.PyNode(self.all_spine_guide[-2]).v.set(0)

        cluster_grp = pm.group(oCollClusters, n='spine_cls__grp__', w=1)
        all_spine_guide_grp = pm.group(self.all_spine_guide,
                                       n='spine_guide__grp__',
                                       w=1)

        self.all_guide.extend(self.all_spine_guide)

        ## Hide loc
        self.locs_grp = pm.group(n='x__locs_pos__grp__')
        pm.parent(self.all_locs, self.locs_grp)
        pm.PyNode(self.locs_grp).v.set(0)

        ## associate shader
        spine_shader = pm.shadingNode('lambert',
                                      asShader=True,
                                      n='yellow_guide_shader')
        pm.setAttr(spine_shader + ".incandescence",
                   0,
                   0.42,
                   0.06,
                   type='double3')

        pm.select(pm.ls(type='nurbsSurface'))

        for spine_guide in pm.selected():
            pm.select(spine_guide)
            pm.hyperShade(assign=spine_shader)

        @changeColor('index', col=(14))
        def create_curve():

            _curve_arm_1 = pm.curve(p=[(2.2, 5, -0.05), (1.45, 5, -0.05)],
                                    k=[0, 1],
                                    d=1)
            _curve_arm_2 = pm.curve(p=[(1.45, 5, -0.05), (0.5, 5, 0)],
                                    k=[0, 1],
                                    d=1)

            _curve_arm_4 = pm.curve(p=[(-2.2, 5, -0.05), (-1.45, 5, -0.05)],
                                    k=[0, 1],
                                    d=1)
            _curve_arm_5 = pm.curve(p=[(-1.45, 5, -0.05), (-0.5, 5, 0)],
                                    k=[0, 1],
                                    d=1)

            r_leg_thigh_curve = pm.curve(p=[(-0.4, 3.2, 0.05),
                                            (-0.4, 1.75, 0.185)],
                                         k=[0, 1],
                                         d=1)
            l_leg_thigh_curve = pm.curve(p=[(0.4, 3.2, 0.05),
                                            (0.4, 1.75, 0.185)],
                                         k=[0, 1],
                                         d=1)

            r_leg_knee_curve = pm.curve(p=[(-0.4, 1.75, 0.185),
                                           (-0.4, 0.35, 0)],
                                        k=[0, 1],
                                        d=1)
            l_leg_knee_curve = pm.curve(p=[(0.4, 1.75, 0.185), (0.4, 0.35, 0)],
                                        k=[0, 1],
                                        d=1)

            all_curves = [
                _curve_arm_1, _curve_arm_2, _curve_arm_4, _curve_arm_5,
                r_leg_thigh_curve, l_leg_thigh_curve, r_leg_knee_curve,
                l_leg_knee_curve
            ]

            self.curves_grp = pm.group(em=True, n='x__curves__grp__', w=True)

            pm.select(self.all_joint, r=True)
            pm.select(all_curves, add=True)

            mc.SmoothBindSkin()

            pm.parent(_curve_arm_1, _curve_arm_2, _curve_arm_4, _curve_arm_5,
                      r_leg_thigh_curve, l_leg_thigh_curve, r_leg_knee_curve,
                      l_leg_knee_curve, self.spine_curve, cluster_grp,
                      self.curves_grp)

            return self.curves_grp

        create_curve()

        guide_scale_grp = pm.group(em=True, n='x__guide__grp__')
        pm.parent('l__arm_clav__guide__root__grp__',
                  'l__arm_elbow__guide__root__grp__',
                  'l__arm_hand__guide__root__grp__',
                  'l__leg_main__guide__root__grp__',
                  'r__arm_clav__guide__root__grp__',
                  'r__arm_elbow__guide__root__grp__',
                  'r__arm_hand__guide__root__grp__',
                  'r__leg_main__guide__root__grp__', 'spine_guide__grp__',
                  guide_scale_grp)

        return guide_scale_grp
Beispiel #19
0
def rig(*args):
    if (jointsMirrored):
        unParentJoints()

        #adds Ik Spline to spine joints
        cmds.select(ikHipJoint)
        cmds.select("spine_6", add=True)
        cmds.ikHandle(n="Spine_IkSolver", sol='ikSplineSolver')
        cmds.rename("curve1", "spine_Curve")
        cmds.rename("effector1", "spine_Effector")
        #binds ik curve to two duplicated joints
        #this part duplicates and cleans the joints

        cmds.select("spine_6")
        cmds.duplicate(n="shoulder_bind_joint")
        cmds.parent("shoulder_bind_joint", w=True)
        cmds.select("shoulder_bind_joint")
        cmds.rotate(0, -90, 0, r=True)

        cmds.select(ikHipJoint)
        cmds.duplicate(n="hip_bind_joint")
        cmds.select("hip_bind_joint")
        if (ikHipJoint != 'root'):
            cmds.parent("hip_bind_joint", w=True)
        cmds.pickWalk(d='down')
        cmds.delete()

        #this binds the curve to the control joints
        cmds.select("shoulder_bind_joint")
        cmds.select("hip_bind_joint", add=True)
        cmds.select("spine_Curve", add=True)
        cmds.SmoothBindSkin(
        )  # this should be binded to the selected joints with a ma influence of 2 but it still works like this
        #this creates the control curves and snaps them in placed
        #hip control curve
        maya.mel.eval(
            'curve -d 1 -p -8.586044 2.072055 8.586044 -p -12.879065 -2.072055 9.948048 -p 12.879065 -2.072055 9.948048 -p 8.586044 2.072055 8.586044 -p -8.586044 2.072055 8.586044 -p -8.586044 2.072055 -8.586044 -p -12.879065 -2.072055 -9.948048 -p -12.879065 -2.072055 9.948048 -p -12.879065 -2.072055 -9.948048 -p 12.879065 -2.072055 -9.948048 -p 8.586044 2.072055 -8.586044 -p -8.586044 2.072055 -8.586044 -p 8.586044 2.072055 -8.586044 -p 8.586044 2.072055 8.586044 -p 12.879065 -2.072055 9.948048 -p 12.879065 -2.072055 -9.948048 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15;'
        )
        cmds.rename('curve1', 'hip_Cotrol')
        cmds.select(ikHipJoint)
        cmds.select('hip_Cotrol', add=True)
        cmds.pointConstraint(offset=[0, 0, 0], weight=1)
        cmds.select('hip_Cotrol_pointConstraint1')
        cmds.Delete()

        #shoulder control curve
        cmds.duplicate('hip_Cotrol', n='shoulder_Control')
        cmds.select('shoulder_bind_joint')
        cmds.select('shoulder_Control', add=True)
        cmds.pointConstraint(offset=[0, 0, 0], weight=1)
        cmds.select('shoulder_Control_pointConstraint1')
        cmds.Delete()
        cmds.select('shoulder_Control')
        cmds.scale(0.650436, -1, 0.650436, r=True)

        # this was not part of the tutorial
        #
        cmds.select('shoulder_Control')
        cmds.select('hip_Cotrol', add=True)
        cmds.FreezeTransformations()
        #
        #

        #changes rotate order to zxy on hip control
        cmds.setAttr("hip_Cotrol.rotateOrder", 2)
        cmds.setAttr("shoulder_Control.rotateOrder", 2)
        cmds.setAttr("hip_bind_joint.rotateOrder", 2)
        #cmds.setAttr("shoulder_bind_joint_parentConstraint1.rotateOrder" , 2)#not sure about this one either
        #cmds.setAttr("hip_bind_joint_parentConstraint1.rotateOrder", 2)# not sure about this one
        cmds.setAttr("shoulder_bind_joint.rotateOrder", 2)

        # parents the control joints to the control curves (hips and shoulders)
        cmds.select('shoulder_Control')
        cmds.select('shoulder_bind_joint', add=True)
        cmds.parentConstraint(mo=True, weight=1)
        cmds.select(cl=True)
        cmds.select('hip_Cotrol')
        cmds.select('hip_bind_joint', add=True)
        cmds.parentConstraint(mo=True, weight=1)
        #adding twist
        cmds.setAttr("Spine_IkSolver.dTwistControlEnable", 1)
        cmds.setAttr("Spine_IkSolver.dWorldUpType", 4)
        #adds the world up objects
        maya.mel.eval(
            'connectAttr -f hip_bind_joint.worldMatrix[0] Spine_IkSolver.dWorldUpMatrix;'
        )
        maya.mel.eval(
            'connectAttr -f shoulder_bind_joint.worldMatrix[0] Spine_IkSolver.dWorldUpMatrixEnd;'
        )

        maya.mel.eval('setAttr "Spine_IkSolver.dWorldUpAxis" 1;')
        maya.mel.eval('setAttr "Spine_IkSolver.dWorldUpVectorY" -1;')
        maya.mel.eval('setAttr "Spine_IkSolver.dWorldUpVectorEndY" 0;')
        maya.mel.eval('setAttr "Spine_IkSolver.dWorldUpVectorEndZ" -1;')

        #
        #
        #               I added a rotation to the spine top joint to compensate, this fixed the issue but it's not on the steps (lines 196, 197)
        #               part 3 in the tutorial at the end:
        #               https://www.youtube.com/watch?v=ahgIOJysSHg
        #
        #               BELOW IS FK PART 4 OF TUTORIAL

        # this arrays are used to create secondary joints for spine FK
        cmds.select(cl=True)
        spinesForFkSpine = ['root', 'spine_2', 'spine_4', 'spine_6']
        spinesForFkSpine = ['root', 'spine_2', 'spine_4', 'spine_6']
        namesForFkSpine = [
            'spineFKContro1', 'spineFKContro2', 'spineFKContro3',
            'spineFKContro4'
        ]
        # creating secondary joints for spine FK
        for i in range(0, 4):
            cmds.joint(position=[0, 0, 0], n=namesForFkSpine[i])

        for j in range(0, 4):
            cmds.select(spinesForFkSpine[j])
            cmds.select(namesForFkSpine[j], add=True)
            cmds.pointConstraint(offset=[0, 0, 0], weight=1, n='temp')
            cmds.select('temp')
            cmds.Delete()

        ParentJoints()
    else:
        print("All joints must be placed before control rig is added.")
Beispiel #20
0
def FreezeTransforms():
    selection = cmds.ls(selection = True)
    for items in selection
        cmds.FreezeTransformations(0)
Beispiel #21
0
def flowerMaker():
    numPetals = 10
    hasShader = False
    ## Check for shader
    shades = cmds.ls(mat=True)
    for myNode in shades:
        if (myNode == "petalColor"):
            hasShader = True

    if hasShader == True:
        print "There is already a shader"
    elif hasShader == False:
        ## Build our shader network
        cmds.shadingNode('lambert', asShader=True, name="petalColor")
        cmds.shadingNode('ramp', asTexture=True, name="petalRamp")
        cmds.sets(empty=True,
                  noSurfaceShader=True,
                  renderable=True,
                  name="petalColorSG")
        cmds.connectAttr('petalColor.outColor',
                         'petalColorSG.surfaceShader',
                         force=True)
        cmds.connectAttr('petalRamp.outColor', 'petalColor.color')

        cmds.setAttr('petalRamp.colorEntryList[3].color',
                     1.0,
                     0.0,
                     0.0,
                     type="double3")
        cmds.setAttr('petalRamp.colorEntryList[3].positon', 1.0)

        cmds.setAttr('petalRamp.colorEntryList[2].color',
                     1.0,
                     1.0,
                     0.0,
                     type="double3")
        cmds.setAttr('petalRamp.colorEntryList[2].positon', 0.5)

        cmds.setAttr('petalRamp.colorEntryList[1].color',
                     1.0,
                     0.0,
                     0.0,
                     type="double")
        cmds.setAttr('petalRamp.colorEntryList[1].positon', 0.0)
        cmds.setAttr('petalRamp.type', 8.0)
    else:
        print "Catastrophic collapse in code!"

    ## Build the flower core
    cmds.sphere(axis=[0.0, 1.0, 0.0], name="core")
    myCore = cmds.ls(selection=True)
    cmds.scale(1.0, 0.5, 1.0)
    cmds.move(0.0, 0.2, 0.0)

    ## Build the petal
    cmds.sphere(axis=[0.0, 1.0, 0.0])
    cmds.move(0.0, 0.0, -1.6)
    cmds.scale(0.7, 0.3, 1.7)
    cmds.FreezeTransformations()
    cmds.ResetTransformations()

    myPetal = cmds.ls(selection=True)
    cmds.parent(myPetal, myCore)
    cmds.select(myPetal[0])
    cmds.pickWalk(direction="down")
    myPetalShape = cmds.ls(selection=True)
    cmds.sets(myPetalShape[0], edit=True, forceElement='petalColorSG')

    # Move the tip of the petal
    cmds.select(myPetal[0] + '.cv[3][7]')
    cmds.move(0.0, 2.0, 0.0, relative=True)

    # Select the inner part of the petal pull down
    # One loop for the U direction
    for uCV in xrange(5, 7):
        for vCV in xrange(0, 8):
            cmds.select(myPetal[0] + '.cv[' + str(uCV) + '][' + str(vCV) + ']')
            cmds.move(0.0, -0.4, 0.0, relative=True)

    cmds.select(myPetal[0])
    degreeApart = (360.0 / numPetals)
    for x in xrange(1, numPetals):
        cmds.duplicate()
        cmds.rotate(0.0, degreeApart, 0.0, relative=True)

    cmds.select(myCore)
    cmds.rename("Flower")
Beispiel #22
0
def makeFlower():
    ## Number of petals on the flower
    numPetals = 10
    
    ## Shaders for the flower
    myShader = cmds.shadingNode('lambert', n = "core", asShader = True)
    myShader1 = cmds.shadingNode('lambert', n = "petal", asShader = True)
    
    ## Build the flower core
    cmds.sphere(axis = [0.0, 1.0, 0.0], name = "core")
    myCore = cmds.ls(selection = True)
    cmds.scale(1.0, 0.5, 1.0)
    cmds.move(0.0, 0.2, 0.0)
    
    ## Colors the core of the flower
    cmds.select(myCore)
    shaderSet = cmds.sets(renderable = True, noSurfaceShader = True, empty = True, name = myShader + 'SG')
    cmds.setAttr(myShader + '.color', 0.18, 0.40, 0.698, type = 'double3')
    ##cmds.setAttr(myShader + '.incandescence', 0.0, 0.0, 0.0, type = 'double3')
    cmds.connectAttr(myShader + ".outColor", shaderSet + ".surfaceShader")
    cmds.sets(forceElement = shaderSet, e = True)
    
    ## Build the petal
    cmds.sphere(axis = [0.0, 1.0, 0.0])
    cmds.move(0.0, 0.0, -1.6)
    cmds.scale(0.7, 0.3, 1.7)
    cmds.FreezeTransformations()
    cmds.ResetTransformations()
    myPetal = cmds.ls(selection = True)
    
    # Curve the tip of the petal
    cmds.select(myPetal[0] + '.cv[3][7]')
    cmds.move(0.0, 2.0, 0.0, relative = True)
    
    # Select the inner part of the petal pull down
    # One loop for the U direction
    for uCV in xrange(5,7):
        for vCV in xrange(0,8):
            cmds.select(myPetal[0] + '.cv[' + str(uCV) + '][' + str(vCV) + ']')
            cmds.move(0.0, -0.4, 0.0, relative = True)
    
    ## Color the petal of the flower
    cmds.select(myPetal)
    shaderSet1 = cmds.sets(renderable = True, noSurfaceShader = True, empty = True, name = myShader1 + 'SG')
    cmds.setAttr(myShader1 + '.color', 1.0, 0.361, 0.169, type = 'double3')
    ##cmds.setAttr(myShader1 + '.incandescence', 0.0, 0.0, 0.0, type = 'double3')
    cmds.connectAttr(myShader1 + ".outColor", shaderSet1 + ".surfaceShader")
    cmds.sets(forceElement = shaderSet1, e = True)
    
    ## Parent the petal to the core of the flower
    cmds.parent(myPetal, myCore)
    cmds.select(myPetal[0])
    cmds.pickWalk(direction="down")
    
    ## Duplicates the petals and rotates them around the core
    cmds.select(myPetal[0])
    degreeApart = (360.0/numPetals)
    for x in xrange(1,numPetals):
        cmds.duplicate()
        cmds.rotate(0.0, degreeApart, 0.0, relative = True)
    cmds.select(myCore)
Beispiel #23
0
def flowerMaker():

    numPetals = 10
    createShader = 1

    #Check for Shader
    shads = cm.ls(materials=True)
    for myNode in shads:
        if myNode == "petalColor":
            createShader = 0

    if createShader == 0:
        print "The Shader is already there \n"
    elif createShader == 1:
        #build our shader network
        cm.shadingNode("lambert", asShader=True, name="petalColor")
        cm.shadingNode("ramp", asTexture=True, name="petalRamp")
        cm.sets(renderable=True,
                noSurfaceShader=True,
                empty=True,
                n="petalColorSG")
        cm.connectAttr("petalColor.outColor",
                       "petalColorSG.surfaceShader",
                       force=True)
        cm.connectAttr("petalRamp.outColor", "petalColor.color")

        cm.setAttr("petalRamp.colorEntryList[3].color",
                   1,
                   0,
                   0,
                   type="double3")
        cm.setAttr("petalRamp.colorEntryList[3].position", 1)

        cm.setAttr("petalRamp.colorEntryList[2].color",
                   1,
                   1,
                   0,
                   type="double3")
        cm.setAttr("petalRamp.colorEntryList[2].position", 0.5)

        cm.setAttr("petalRamp.colorEntryList[1].color",
                   1,
                   0,
                   0,
                   type="double3")
        cm.setAttr("petalRamp.colorEntryList[1].position", 0)
        cm.setAttr("petalRamp.type", 8)

    #build the flower core
    cm.sphere(ax=[0, 1, 0], name="core")
    myCore = cm.ls(sl=True)
    cm.scale(1, 0.5, 1)
    cm.move(0, 0.2, 0)

    #build the petal
    cm.sphere(ax=[0, 1, 0])
    cm.move(0, 0, -1.6)
    cm.scale(0.7, 0.3, 1.7)
    cm.FreezeTransformations()
    cm.ResetTransformations()

    myPetal = cm.ls(sl=True)
    cm.parent(myPetal, myCore)
    cm.select(myPetal[0])
    cm.pickWalk(d="down")
    myPetalShape = cm.ls(sl=True)
    cm.sets(myPetalShape[0], edit=True, forceElement="petalColorSG")

    #move the tip of the petal
    cm.select(myPetal[0] + ".cv[3] [7]")
    cm.move(0, 2, 0, r=True)

    #Select the inner part of the petal pull down
    #One loop for the U direction
    for uCV in range(5, 7):
        for vCV in range(0, 8):
            cm.select(myPetal[0] + ".cv[{0}][{1}]".format(uCV, vCV))
            cm.move(0, -0.4, 0, r=True)

    cm.select(myPetal[0])
    degreeApart = 360 / numPetals
    for i in range(2, numPetals + 1):
        cm.duplicate()
        cm.rotate(0, degreeApart, 0, r=True)

    cm.select(myCore)
    cm.rename("Flower")
 def mainCtrl_offset():
     main_ctrl_offset = sl.circleY_shape()
     main_ctrl_offset.setScale((1.82, 1.82, 1.82))
     mc.FreezeTransformations()
     return main_ctrl_offset
Beispiel #25
0
nurb = cmds.nurbsPlane(n='upEyelidMain_l_nurbs', ax=(0,1,0), w=True, lr= True, d = 3, u = 15, v=1, ch=1) 


#Creation

#Main Structure
cmds.duplicate('upEyelidMain_l_nurbs', n='dwEyelidMain_l_nurbs')

cmds.duplicate('upEyelidMain_l_nurbs', n='dwEyelidMain_r_nurbs')
cmds.duplicate('upEyelidMain_l_nurbs', n='upEyelidMain_r_nurbs')

inv = cmds.group(em=True)
cmds.parent('upEyelidMain_r_nurbs', 'dwEyelidMain_r_nurbs', inv)
cmds.setAttr('{}.sx'.format(inv), -1)
cmds.select(inv)
cmds.FreezeTransformations(inv)

for side in 'rl':
    for position in ['up', 'dw']:
        name = '{}EyelidSpecific_{}_nurbs'.format(position, side)
        specific = cmds.duplicate('{}EyelidMain_{}_nurbs'.format(position, side), n=name)
        bs = cmds.blendShape('{}EyelidSpecific_{}_nurbs'.format(position, side), '{}EyelidMain_{}_nurbs'.format(position, side), n='{}EyelidMain_{}_bs'.format(position, side))
        cmds.setAttr('{}.{}'.format(bs[0], specific[0]), 1)
        cmds.parent(specific, 'eyelidsSpecificSkin_{}_grp'.format(side))
        cmds.parent('{}EyelidMain_{}_nurbs'.format(position, side), 'eyelidsMainSkin_{}_grp'.format(side))
        
for side in 'rl':
    pos = cmds.xform('centerEyelids_{}_loc'.format(side), q=True, ws=True, m=True)
    for position in ['up', 'ext', 'int', 'dw']:
        if position != 'dw':
            ctrJnt = fun.createControlJoint(control_name = '{}EyelidsMain'.format(position),
Beispiel #26
0
def flowerMaker(nf):
    #erases anything on stage creates a new file
    #cmds.file( f=True, new=True)
    #sets plaback time
    numPetals = 10
    createShader = 1
    #Check for Shader
    shads = cmds.ls()
    for myNode in shads:
        if myNode == "petalColor":
            createShader = 0

    if createShader == 0:
        print "The Shader is already there \n"

    elif createShader == 1:
        cmds.shadingNode('lambert', n="petalColor", asShader=True)
        cmds.shadingNode('ramp', asTexture=True, n="petalRamp")
        cmds.sets(renderable=True,
                  empty=True,
                  noSurfaceShader=True,
                  n='petalColorSG')
        cmds.connectAttr('petalColor.outColor',
                         'petalColorSG.surfaceShader',
                         f=True)
        cmds.connectAttr('petalRamp.outColor', 'petalColor.color')
        cmds.setAttr("petalRamp.colorEntryList[3].color",
                     1,
                     1,
                     0.5,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[3].position", 1)
        cmds.setAttr("petalRamp.colorEntryList[2].color",
                     1,
                     1,
                     1,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[2].position", .5)
        cmds.setAttr("petalRamp.colorEntryList[1].color",
                     1,
                     0.5,
                     0.5,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[1].position", 0)
        cmds.setAttr('petalRamp.type', 8)

        cmds.shadingNode('lambert', n="coreColor", asShader=True)
        cmds.shadingNode('ramp', asTexture=True, n="coreRamp")
        cmds.sets(renderable=True,
                  empty=True,
                  noSurfaceShader=True,
                  n='coreColorSG')
        cmds.connectAttr('coreColor.outColor',
                         'coreColorSG.surfaceShader',
                         f=True)
        cmds.connectAttr('coreRamp.outColor', 'coreColor.color')
        cmds.setAttr("coreRamp.colorEntryList[3].color",
                     1,
                     1,
                     0.5,
                     type='double3')
        cmds.setAttr("coreRamp.colorEntryList[3].position", 1)
        cmds.setAttr("coreRamp.colorEntryList[1].color",
                     1,
                     0.5,
                     0.5,
                     type='double3')
        cmds.setAttr("coreRamp.colorEntryList[1].position", 0)
        cmds.setAttr('coreRamp.type', 8)

    cmds.sphere(ax=(0, 1, 0), n="core")
    #build the flower core
    myCore = cmds.ls(sl=1)
    cmds.scale(1, .5, 1)
    cmds.move(0, 0.2, 0)
    cmds.sets(myCore[0], edit=True, forceElement='coreColorSG')
    #build the petal
    cmds.sphere(ax=(0, 1, 0))
    cmds.move(0, 0, -1.6)
    cmds.scale(.7, .3, 1.7)
    cmds.FreezeTransformations()
    cmds.ResetTransformations()
    myPetal = cmds.ls(sl=1)
    cmds.parent(myPetal, myCore, shape=True)
    cmds.select(myPetal[0])
    cmds.pickWalk(d='down')
    myPetalShape = cmds.ls(sl=1)
    cmds.sets(myPetalShape[0], edit=True, forceElement='petalColorSG')
    #move the tip of the petal
    cmds.select(myPetal[0] + ".cv[3][7]")
    cmds.move(0, 2, 0, r=1)
    #Select the inner part of the petal pull down
    #One loop for the U direction
    for uCV in range(5, 7):
        for vCV in range(0, 8):
            cmds.select(myPetal[0] + ".cv[" + str(uCV) + "][" + str(vCV) + "]")
            cmds.move(0, -0.4, 0, r=1)

    cmds.select(myPetal[0])
    degreeApart = float((360 / numPetals))

    for k in range(3):
        if k is not 0:
            cmds.duplicate()
            cmds.scale((k % 2 + 1) * 0.5)
            cmds.rotate(k * 20, k * 20)
        for i in range(2, numPetals + 1):
            cmds.duplicate()
            cmds.rotate(0, degreeApart, 0, r=1)

    cmds.select(myCore)
    cmds.rename('Flower' + str(nf))