Example #1
0
 def FKcontrolMaker(self):
     sel = cmds.ls(sl=True)
     fkController = []
     fkNullGroup = []
     print self.temp_CON
     for i in sel:
         jointName = i
         if len(self.temp_CON) == 1:
             Control = cmds.duplicate(self.temp_CON, n= jointName.replace(jointName.split('_')[-1],'CON'))
             print Control
         else:
             Control = cmds.circle(nr=(1,0,0),c=(0,0,0),r=1, n= jointName.replace(jointName.split('_')[-1],'CON'))
             cmds.DeleteHistory(Control[0])
             print Control
         cmds.setAttr("%sShape.overrideEnabled" %Control[0], 1)
         cmds.setAttr("%sShape.overrideColor" %Control[0], 17)
         cmds.DeleteHistory(Control[0])
         cmds.group( Control[0] )
         nullGroup = (cmds.rename(jointName.replace(jointName.split('_')[-1],'NUL')))
         fkController.append("%s" %Control[0])
         fkNullGroup.append("%s" %nullGroup)
         cmds.delete(cmds.parentConstraint(jointName,nullGroup, w=True))
     for x in range(len(sel)-1):
         q = -1-x
         k = -2-x
         cmds.parent(fkNullGroup[q], fkController[k])
     for y in range(len(sel)):
         cmds.parentConstraint(fkController[y], sel[y], mo=1 , w=1)
def makeNewBlendshapes(default_blendshape, target_mesh_final):
    '''Make a new, clean piece of geometry from new mesh for every blendshape on old geometry.'''
    blendshape_nodes = utils.getBlendShapeNode(default_blendshape)
    blendshapes = utils.getBlendShapesFromNodes(default_blendshape, blendshape_nodes)
    
    new_bs_group = cmds.group(empty=True, name='BlendShape_GRP')
    
    for current_bs in blendshapes:
        name = newBlendShapeNames(current_bs)

        cmds.setAttr(current_bs, 1.0)
        
        new_bs_mesh = cmds.duplicate(target_mesh_final)
        cmds.parent(new_bs_mesh, new_bs_group)
        
        new_bs_mesh = cmds.rename(new_bs_mesh, name)
        cmds.move(0, 0, 0)
        cmds.DeleteHistory(new_bs_mesh)
        cmds.hide(new_bs_mesh)
        cmds.setAttr(current_bs, 0)
        
    cmds.delete(target_mesh_final)
    cmds.DeleteHistory()
        
    return new_bs_group
def cleanProcedure():
    cmds.undoInfo(ock=1)
    sel = cmds.ls(sl=1)
    selRelatives = cmds.listRelatives(sel)
    if selRelatives[0].startswith('instanceAlongCurveLocator'):
        selectedLocator = []
        selectedLocator=cmds.ls(sl=1)
        tempGroupName = ""
        tempGroupName=str(cmds.group(em=1, n='InstanceMesh'))
        selectedMesh = []
        selectedMeshDuplicatedShape = []
        selectedThings = []
        cmds.select(selectedLocator)
        selectedThings=cmds.listRelatives(c=1)
        selectedMesh=cmds.filterExpand(sm=12)
        cmds.select(selectedMesh)
        selectedMeshDuplicatedShape=cmds.listRelatives(c=1)
        eachOverride=selectedMeshDuplicatedShape[0] + ".overrideEnabled"
        cmds.setAttr(eachOverride, 1)
        selectedMeshDuplicated=cmds.duplicate()
        cmds.parent(selectedMeshDuplicated, tempGroupName)
        cmds.ungroup(tempGroupName)
        cmds.delete(selectedLocator)
        cmds.select(selectedMeshDuplicated)
        cmds.polyUnite(centerPivot=1, ch=1, mergeUVSets=1)
        separatedMesh = []
        separatedMesh=cmds.polySeparate(ch=1)
        cmds.CenterPivot()
        separatedMeshGroup=cmds.listRelatives(separatedMesh, p=1)
        cmds.select(separatedMeshGroup)
        cmds.select(selectedMeshDuplicated, add=1)
        cmds.ungroup()
        cmds.DeleteHistory()
        resultAll = cmds.ls(sl=1,o=1)
        result = cmds.filterExpand(resultAll,sm=12)
        toDelete = list(set(resultAll).difference(set(result)))
        cmds.delete(toDelete)

    else:
        try:
            selectedForClean=cmds.ls(sl=1)
            cmds.polyCube(sz=1, sy=1, sx=1, d=1, cuv=4, h=1, ch=1, w=1, ax=(0, 1, 0))
            temp_polyCube=cmds.ls(sl=1)
            cmds.select(selectedForClean)
            cmds.select(temp_polyCube, add=1)
            cmds.CombinePolygons()
            temp_BeforeSeparate=cmds.ls(sl=1)
            cmds.SeparatePolygon()
            temp_AfterSeparate=cmds.ls(sl=1)
            cmds.delete(temp_AfterSeparate[- 1])
            cmds.DeleteHistory()
            temp_father=cmds.listRelatives(temp_AfterSeparate[0], p=1)
            cmds.select(temp_BeforeSeparate)
            cmds.ungroup()
            cmds.delete(selectedForClean)
            cmds.CombinePolygons()
            cmds.DeleteHistory()
        except:
            pass
    cmds.undoInfo(cck=1)
def createController():
    if cmds.objExists("L_Hand_ctrl_grp"):
            cmds.warning(WARNING03)
    else:
        bf_int = cmds.intField(basefinger, q=True, v=True)
        sf_int = cmds.intField(subfinger, q=True, v=True)
        
        if cmds.objExists(RHD):
            LR = ["L_", "R_"]
            unparent = [LHD, RHD, "L_Hand_ctrl_grp", "R_Hand_ctrl_grp"]
        else:
            LR = ["L_"]
            unparent = [LHD, "L_Hand_ctrl_grp"]
            
        for f in LR:
            handgrp = cmds.group(em=True, n=f+"Hand_ctrl_grp")
            othergrp = cmds.group(em=True, n=f+"Hand_ctrl_g_grp")
            hand = cmds.circle(nr=(1, 0, 0), n=f+"Hand_ctrl")[0]
            grouping(hand, othergrp, handgrp)
            z = cmds.getAttr("Hand_World.scaleX")
            cmds.scale(1*z,1.2*z,0.8*z, handgrp)
    
            cmds.parentConstraint(f+"Hand", handgrp, mo=False, n="L")
            cmds.delete("L")
            cmds.parentConstraint(hand, f+"Hand")
            cmds.DeleteHistory(f+"Hand_ctrl")
            coloring(f+"Hand_ctrl", 18)
    
            for i in range(1, bf_int+1):
                createCon(i, sf_int, f)
            subCon(bf_int, f)
            subConPlus(bf_int, sf_int, f)
    
            subgrp = cmds.group(em=True, n=f+"Hand_sub_ctrl_g_grp")
            cmds.parentConstraint(f+"Hand", subgrp, mo=False, n="L")
            cmds.delete("L")
            
            cmds.parent(f+"Hand_sub_ctrl_grp", subgrp)
            cmds.parentConstraint(f+"Hand", subgrp)
            cmds.rotate(0,0,0, f+"Hand_sub_ctrl_grp")
    
        cmds.makeIdentity(HW, a=True, s=True)
        cmds.DeleteHistory(HW)
        
        for num in LR:
            grouping(num+"Hand_sub_ctrl_g_grp", num+"Hand_ctrl_grp", HW)
            
        for num1 in [".t", ".r", ".s"]:
            for num2 in ["x", "y", "z"]:
                for num3 in LR:
                    cmds.setAttr(num3+"Hand_sub_ctrl"+num1+num2, l=True, k=False)
    
        for name in unparent:
            cmds.parent(name, w=True)
        cmds.delete(HW)
Example #5
0
def transferUVs():
    cH = cmds.checkBox('cH', q=True, v=True)

    sel = cmds.ls(sl=True)
    for i in range(len(sel)):

        # Handling multiple objects
        if (len(sel) > 2):
            cmds.select(sel[0], r=True)
            cmds.select(sel[i], add=True)
            cmds.transferAttributes(transferUVs=2, sampleSpace=5)

        elif (len(sel) == 2):
            cmds.transferAttributes(transferUVs=2, sampleSpace=5)

        else:
            cmds.error(
                'Please select the source object first, and at least one target object.'
            )

    # Deleting History if chosen
    if (cH == 1):
        cmds.select(sel[1:len(sel)])
        cmds.DeleteHistory()

    cmds.select(sel, r=True)
Example #6
0
def create_box(obj_name):
    """
    Creates a curve box at the origin with the given name

    :param obj_name: name of the box
    :type: str
    """
    #uses curve command to make the box
    cmds.curve(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), (0.5, -0.5, -0.5)],
               knot=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
               name=obj_name)
    cmds.xform(obj_name, absolute=True, scale=[3, 3, 3])

    # adds the globabl attr
    cmds.addAttr('|' + obj_name,
                 longName=NamingConventionEnums.GLOBAL_ATTR_NAME,
                 attributeType='bool')
    #clear history
    cmds.select(obj_name)
    cmds.DeleteHistory()
    return obj_name
Example #7
0
def main(selection, *args):
    print "COMPUTING FRAMES..."
    id = 0
    for item in selection:

        #Progress bar
        cmds.separator(height=10, style="none")
        cmds.separator(height=10, style="none")
        cmds.text(label="")
        progressControl = cmds.progressBar(h=25, width=385, max=len(selection))
        cmds.separator(height=10, style="none")
        cmds.separator(height=10, style="none")
        cmds.progressBar(progressControl, edit=True, step=1)

        copyUVSet(item)
        modifyUVs(item, id)
        print str(id + 1) + "/" + str(len(selection)) + " PROCESSED"
        id += 1

    print "COMBINGING MESHES..."
    cmds.select(selection)
    cmds.polyUnite(muv=True)
    cmds.progressBar(progressControl, edit=True, step=1)
    cmds.DeleteHistory()
    print "FINSIHED"
Example #8
0
def B_BtoC(*args):
    
    getSelect=mc.ls(sl=True)
    
    for each in getSelect:
        #mc.select(each)        
        #mc.ConvertSelectionToEdgePerimeter()
        #sel = mc.ls(sl= True)
        #selA = mc.select(sel[1])
        #mc.SelectEdgeLoopSp()
        #mc.CreateCluster()
        #mc.rename("ClusterTps")
        #selClu = mc.ls(sl= True)
        mc.select(each)        
        mc.ConvertSelectionToEdgePerimeter()
        mc.ConvertSelectionToFaces()
        mc.ConvertSelectionToContainedEdges()
        sel = mc.ls(sl= True)
        selO = mc.ls(os= True)
        selA = mc.select(selO[1])
        mc.SelectEdgeLoopSp()
        mc.polyToCurve(form= 2,degree= 1,conformToSmoothMeshPreview= 0)      
        mc.CenterPivot()
        mc.DeleteHistory()
        mc.rename("Curve_0")
        selCurv = mc.ls(sl= True)
        posX = mc.getAttr(selCurv[0]+".controlPoints[0].xValue")
        posY = mc.getAttr(selCurv[0]+".controlPoints[0].yValue")
        posZ = mc.getAttr(selCurv[0]+".controlPoints[0].zValue")
        mc.move(posX, posY, posZ, selCurv[0] + ".scalePivot", selCurv[0] + ".rotatePivot", absolute=True)
Example #9
0
def CreateBaseJoint():
    if cmds.objExists("Root"):
        cmds.warning("Basic Jnts are already exists")
    else:
        root=cmds.joint(n="Root", p=(0,9.82,-0.17))
        cmds.select("Root")
        cmds.joint(n="Spine1", p=(0,11.5,-0.4))
        cmds.joint(n="Chest", p=(0,13,-0.55))
        cmds.joint(n="Neck", p=(0,14.1,-0.38))
        cmds.joint(n="Head", p=(0,15.7,-0.1))
        cmds.joint(n="HeadEnd", p=(0,17.1,-0.1))
        
        cmds.select("Head")
        cmds.joint(n="Jaw", p=(0,15.4,0.3))
        cmds.joint(n="JawEnd", p=(0,14.9,1.25))
        cmds.select("Head")
        cmds.joint(n="L_Eye", p=(0.34,15.9,0.9))
        cmds.joint(n="L_EyeEnd", p=(0.34,15.9,1.5))
        JntArm()
        JntLeg()
        
        a=cmds.circle(nr=(0,1,0), n="world_ctrl")
        cmds.scale(3,3,3, a)
        cmds.makeIdentity(a=True, t=True, r=True, s=True, n=0)
        cmds.DeleteHistory(a)
        cmds.parent("Root","world_ctrl")
        print "Create Base Jnts"
Example #10
0
 def controllerResize(self):
     number = float(self.ui.Do_Resize_DSB.text())
     XYZ = ["X", "Y", "Z"]
     sel = cmds.ls(sl=True)
     for x in sel:
         curveName = x
         curveShape = cmds.listRelatives(curveName, s=True)[0]
         cvNum = cmds.getAttr('%s.spans' % curveShape) + cmds.getAttr(
             '%s.degree' % curveShape)
         conPivot = cmds.xform("%s" % curveName, q=True, ws=True, rp=True)
         cmds.select("%s.cv[0:%s]" % (curveName, cvNum))
         cluster = cmds.cluster()
         cmds.move(conPivot[0],
                   conPivot[1],
                   conPivot[2],
                   "%s.scalePivot" % cluster[1],
                   "%s.rotatePivot" % cluster[1],
                   absolute=True)
         if number > 0:
             for i in XYZ:
                 cmds.setAttr("%s.scale%s" % (cluster[1], i), number)
         else:
             nagative_number = 1 - number * (-0.1)
             print nagative_number
             for i in XYZ:
                 cmds.setAttr("%s.scale%s" % (cluster[1], i),
                              nagative_number)
         cmds.DeleteHistory(cmds.select(sel))
Example #11
0
def create_star_control(obj_name):
    """
    creates a 4 point star shape curve

    :param obj_name: what to name the control
    :type: str
    """
    create_circle(obj_name, normal_x=1)
    cmds.select(obj_name + ".cv[0]", obj_name + ".cv[2]", obj_name + ".cv[4]",
                obj_name + ".cv[6]")
    cmds.scale(0.19, 0.19, 0.19, relative=True)
    cmds.select(clear=True)
    cmds.xform(obj_name, scale=(1.27, 1.27, 1.27))
    cmds.select(obj_name)
    cmds.xform(scale=(3, 3, 3))
    cmds.makeIdentity(obj_name,
                      apply=True,
                      translate=True,
                      rotate=True,
                      scale=True,
                      normal=False,
                      preserveNormals=1)
    cmds.makeIdentity(apply=True,
                      translate=1,
                      rotate=1,
                      scale=1,
                      normal=0,
                      pn=1)
    #clear history
    cmds.select(obj_name)
    cmds.DeleteHistory()
Example #12
0
 def finalize(self):
     """ corrective shape finalize """
     mesh = self.mesh
     if not mesh:
         sels = cmds.ls(sl=1)
         if sels:
             mesh = sels[0]
         #END if
     #END if
     assert mesh, "--\ncorrectiveData.createCorrectiveUI.__finalize: no mesh specified"
     corrs = cmds.ls(type="correctiveShape")
     if not corrs:
         print "No corrective shapes found in " + mesh + "'s history"
         return
     #END if
     csp = corrs[0]
     sculpt = cmds.listConnections(csp + ".inputMesh")
     shape = cmds.listConnections(csp + ".og[0]")
     if sculpt:
         sculptShapes = cmds.listRelatives(sculpt[0], s=True, ad=True)
         sculpt.insert(0, sculptShapes[0])
     #END if
     cmds.delete(sculpt)
     cmds.select(shape[0])
     cmds.DeleteHistory()
Example #13
0
def getcuthead():
    seledge = mc.ls(sl=True)
    basename = seledge[0].split('.')
    if len(basename) > 1:
        if basename[1].find('e') > -1:
            basevtx = mc.polyEvaluate(basename[0], v=True)
            mc.DetachEdgeComponent()
            mc.select(basename[0])
            mc.ExtractFace()
            cuts = mc.ls(sl=True)
            mc.duplicate(cuts[0], n='cuthead', rr=True)
            mc.move(1, 0, 0, 'cuthead')
            mc.select(cuts[0], cuts[1])
            mc.CombinePolygons()
            newbase = mc.ls(sl=True)
            mc.polyMergeVertex(newbase[0] + '.vtx[0:99999]',
                               d=.00001,
                               am=1,
                               ch=1)
            mc.select(newbase)
            mc.DeleteHistory()
            if basevtx == mc.polyEvaluate(newbase, v=True):
                mm.eval('print "/////点数一致,切头成功"')
            else:
                mc.warning("点数不一致,切头失败!!!")
        else:
            mc.warning("请选择模型环线执行!!!")
    else:
        mc.warning("请选择模型环线执行!!!")


#shuai_autoFacialRig()
def subCon(base, f):
    if f == "L_":
        sweep = -180
        centerX = 0.2
    else:
        sweep = 180
        centerX = -0.2
    cir = cmds.circle(r=1.5,nr=(0,0,1), sw=sweep, cx=centerX, n=f+"Hand_sub_ctrl")[0]
    
    grp = cmds.group(em=True, n=f+"Hand_sub_ctrl_grp")
    cmds.parent(cir, grp)
    z = cmds.getAttr("Hand_World.scaleX")
    cmds.scale(2.5*z,1*z,1*z, grp)
    cmds.DeleteHistory(cir)
    c = f+"Hand_sub_ctrl_grp"
    
    base = base+1
    for x in range(2, base):
        cmds.orientConstraint(f+"finger_"+str(x)+"_1", c, mo=False, n="sub"+str(x))
    cmds.parentConstraint(f+"Hand", c, n="sub")
    cmds.delete("sub*")
    coloring(c,17)
    
    for n in range(1, base):
        cmds.addAttr(f+"Hand_sub_ctrl", ln="finger_"+str(n), at="float", dv=0, max=10, min=-5, k=True)
Example #15
0
def gameOpt():

    # dialogue box
    softenEdgeDialogue = cmds.confirmDialog(t='Soften Edges',
                                            b=['Yes', 'No'],
                                            defaultButton='Yes',
                                            cancelButton='No',
                                            dismissString='No')

    # this softens the mesh's edges, should the user click 'Yes'
    if softenEdgeDialogue == 'Yes':
        for i in objs:
            cmds.select(i)
            cmds.polySoftEdge(a=180)

    # this runs optimization commands for game engine
    for i in objs:
        cmds.select(i)
        cmds.snapMode(gr=True)
        cmds.move(rpr=True)
        cmds.snapMode(gr=False)
        cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0, pn=1)
        cmds.DeleteHistory()
    # deselect
    cmds.select(clear=True)
Example #16
0
def convert():
    cmds.file(f=1, new=1)
    #模型的文件路径,请自行改动
    path = "C:/Users/Lan/Desktop/jf_lan/Test"
    files = os.listdir(path)
    index = 0
    groupIndex = 0
    lastString = "0000"
    currentString = "0000"
    fileIndexToName = {}

    for afile in files:
        if (str.isdigit(afile[3:7])):
            if index == 0:
                fileIndexToName[groupIndex] = {afile}
            else:
                if afile[3:7] == lastString:
                    fileIndexToName[groupIndex].add(afile)
                else:
                    lastString = afile[3:7]
                    groupIndex += 1
                    fileIndexToName[groupIndex] = {afile}
            index += 1

    if cmds.pluginInfo("fbxmaya", q=1, l=1) != 1:
        mds.loadPlugin("fbxmaya", qt=1)

    axis = ['x', 'y', 'z']
    attrs = ['t', 'r', 's']

    for groupName, value in fileIndexToName.items():
        for apath in value:
            cmds.file(path + "/" + apath,
                      i=True,
                      mergeNamespacesOnClash=True,
                      namespace=':')
        cmds.select('NULL', r=1)
        cmds.delete()
        cmds.select(all=1)
        sel = cmds.ls(sl=1, transforms=1)
        for obj in sel:
            for ax in axis:
                for attr in attrs:
                    cmds.setAttr(obj + '.' + attr + ax, lock=0)
        cmds.select(all=1)
        fbxExportName = path + "/" + str(groupName) + list(value)[0] + ".fbx"
        mel.eval('FBXExportScaleFactor 1;')
        mel.eval('FBXExportInAscii -v 1;')
        mel.eval('FBXExportSmoothingGroups -v 1;')
        mel.eval('FBXExportSmoothMesh -v 1;')
        mel.eval('FBXExportTriangulate -v 0;')
        mel.eval('FBXExportUpAxis y;')
        mel.eval('FBXExport -f "' + fbxExportName + '" -s;')
        cmds.select(all=1)
        cmds.delete()
        cmds.flushUndo()
        cmds.clearCache(all=True)
        cmds.DeleteHistory()
Example #17
0
    def toCombinedObj(self, name):
        oldMeshes = self.meshs[:]
        self.combineData(name)

        newMesh = mc.polyUnite(oldMeshes)[0]
        mc.DeleteHistory(newMesh)
        mc.rename(newMesh, name)
        self.toObjs()
        return name
Example #18
0
def defControl():
    grp = cmds.group(em=True, name="_ctrl_grp")
    ctrl = cmds.circle(name="_ctrl")
    loc_name = "_CTRL_LOC"
    loc = cmds.CreateLocator()
    cmds.rename(loc, loc_name)
    cmds.parent(ctrl, loc_name)
    cmds.parent(loc_name, grp)
    cmds.DeleteHistory(ctrl)
Example #19
0
    def random_spawner(self, amount, grow_flag, move_range, scale_lower,
                       scale_upper):
        """
        Randomly places duplicates of selected object around object
        input: int, boolean, float, float, float
        return: none
        """
        spawn_num = 1
        selection = cmds.ls(sl=True)
        polygons = cmds.filterExpand(selection, sm=12)
        if len(polygons) > 1:
            poly = cmds.polyUnite(polygons)
        else:
            poly = polygons
        cmds.rename(poly[0], 'Spawn_' + str(spawn_num))
        polygons[0] = 'Spawn_' + str(spawn_num)
        cmds.DeleteHistory((polygons[0]))
        cmds.xform('Spawn_' + str(spawn_num), pivots=(0, 0, 0), ws=True)
        if grow_flag:
            i = 0
            while i < amount:
                polygon = cmds.duplicate('Spawn_' + str(spawn_num))
                cmds.rename(polygon[0], 'CurrentSpawn')
                current_position = cmds.xform('CurrentSpawn',
                                              ws=True,
                                              query=True,
                                              translation=True)
                move_adj_x = random.randrange(-1 * move_range, move_range)
                move_adj_z = random.randrange(-1 * move_range, move_range)
                x = current_position[0] + move_adj_x
                y = current_position[1]
                z = current_position[2] + move_adj_z
                scale_adj = random.randrange(scale_lower, scale_upper)
                cmds.scale(scale_adj, scale_adj, scale_adj, 'CurrentSpawn')
                cmds.move(x, y, z, 'CurrentSpawn')
                spawn_num += 1
                cmds.rename('CurrentSpawn', 'Spawn_' + str(spawn_num))
                polygons[len(polygons) - 1] = 'Spawn_' + str(spawn_num)
                i += 1
        else:
            i = 0
            while i < amount:
                polygon = cmds.duplicate('Spawn_' + str(spawn_num))
                cmds.rename(polygon[0], 'CurrentSpawn')
                x = random.randrange(-1 * move_range, move_range)
                z = random.randrange(-1 * move_range, move_range)
                scale_adj = random.randrange(scale_lower, scale_upper)
                cmds.scale(scale_adj, scale_adj, scale_adj, 'CurrentSpawn')
                cmds.move(x, 0, z, 'CurrentSpawn', ws=True)
                spawn_num += 1
                cmds.rename('CurrentSpawn', 'Spawn_' + str(spawn_num))
                polygons[len(polygons) - 1] = 'Spawn_' + str(spawn_num)
                i += 1

        cmds.group(polygons, name='Geometry')
Example #20
0
def cici():
    import maya.cmds as lj
    import maya.mel as mm
    sele = cmds.ls(sl=1)
    pipei = cmds.radioButtonGrp('pipei',q=1,sl=1)
    maya=cmds.textFieldButtonGrp('zong',q=1,tx=1)
    name = cmds.textField('w',q=1,tx=1)
    for i in sele:
        a = []
        a =i.split('.')
        c=a[1][2:-1]
        curve1 = cmds.polyToCurve(i,form=2,degree=3)
        cmds.DeleteHistory(curve1)
        edge =cmds.createNode("curveFromMeshEdge",n='new_CFME_#')
        poc =cmds.createNode("pointOnCurveInfo",n='new_poc_#')
        joint_t =cmds.createNode("joint",n=name+'_Jt_#')
        jt_grp = cmds.group(joint_t,n=name+'_Jt_Gp_#')
        cmds.setAttr(poc+'.turnOnPercentage',1)
        cmds.setAttr(poc+'.parameter',1)
        MD =cmds.createNode("multiplyDivide",n='new_MD_#')
        cmds.setAttr(MD+'.input2Z',-1)
        cmds.setAttr(MD+'.input2X',-1)
        cmds.setAttr(MD+'.input2Y',-1)
        shape = cmds.listRelatives(a[0],s=1)
        shape1 = cmds.listRelatives(curve1[0],s=1)
        cmds.setAttr(edge+'.edgeIndex[0]',int(c))
        kong = cmds.curve(n=name,d=1,p=[(0,0,1),(0,0.5,0.866025),(0,0.866025,0.5),(0,1,0),(0,0.866025,-0.5),(0,0.5,-0.866025),(0,0,-1),(0,-0.5,-0.866025),(0,-0.866025,-0.5),(0,-1,0),(0,-0.866025,0.5),(0,-0.5,0.866025),(0,0,1),(0.707107,0,0.707107),(1,0,0),(0.707107,0,-0.707107),(0,0,-1),(-0.707107,0,-0.707107),(-1,0,0),(-0.866025,0.5,0),(-0.5,0.866025,0),(0,1,0),(0.5,0.866025,0),(0.866025,0.5,0),(1,0,0),(0.866025,-0.5,0),(0.5,-0.866025,0),(0,-1,0),(-0.5,-0.866025,0),(-0.866025,-0.5,0),(-1,0,0),(-0.707107,0,0.707107),(0,0,1)],k=[0,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])
        grp0 = cmds.group(kong,n=name+'_Subtract')
        grp1 = cmds.group(grp0,n=name+'_Offset')
        grp2 = cmds.group(grp1,n=name+'_Attach')
        cmds.connectAttr(shape[0]+'.worldMesh[0]',edge+'.inputMesh')
        cmds.connectAttr(edge+'.outputCurve',shape1[0]+'.create')
        cmds.connectAttr(shape1[0]+'.worldSpace[0]',poc+'.inputCurve')
        cmds.connectAttr(poc+'.position',grp2+'.translate')
        cmds.connectAttr(kong+'.translate',MD+'.input1')
        cmds.connectAttr(MD+'.output',grp0+'.translate')
        cmds.delete(cmds.parentConstraint(kong,jt_grp,w=1))
        cmds.connectAttr(kong+'.translate',joint_t+'.translate')
        cmds.connectAttr(kong+'.rotate',joint_t+'.rotate')
        cmds.connectAttr(kong+'.scale',joint_t+'.scale')
        cmds.select(kong+'.cv[0:32]')
        cmds.scale(0.01,0.01,0.01)
        se = cmds.listRelatives(kong,shapes=True)
        cmds.setAttr(se[0]+'.overrideEnabled',1)
        cmds.setAttr(se[0]+'.overrideColor',17)
        cmds.select(cl=1)
        if (pipei == 1):
            cmds.connectAttr('Brs.rotate',grp2+'.rotate')
            cmds.connectAttr('Brs.scale',grp2+'.scale')
            cmds.parent(curve1[0],'ClusterSetup')
            cmds.parent(jt_grp,'FaceAttachToHead')
            cmds.setAttr(curve1[0]+'.v',0)
        if (pipei == 2):
            cmds.connectAttr(maya+'.rotate',grp2+'.rotate')
            cmds.connectAttr(maya+'.scale',grp2+'.scale')
Example #21
0
    def polyCenterCurves(self, *args):
        cmd.select(self.curve1)
        cur1 = cmd.polyToCurve(f=2, dg=3)
        cmd.DeleteHistory(cur1[0])
        cmd.select(self.curve2)
        cur2 = cmd.polyToCurve(f=2, dg=3)
        cmd.DeleteHistory(cur2[0])

        self.point = []
        self.pointOnCur(cur1[0], cur2[0])
        cmd.delete(cur1[0], cur2[0])

        int_i = len(self.point)
        for pi in range(0, int_i):
            if pi == 0:
                centerCur = cmd.curve(d=3, p=self.point[pi], k=[0, 0, 0])
            else:
                cmd.curve(centerCur, a=1, p=self.point[pi])
        cmd.select(cl=1)
        print "////生成完毕" + "\n",
Example #22
0
    def createChunksFromGeo(self, currHair, loopDict):
        import pprint as pp

        hairChunksGRP = cmds.createNode("transform",
                                        name="{0}_hairChunksGeo_GRP".format(
                                            currHair.name()))
        deleted = False
        newHair = None

        justIndexDict = {}
        for edge in sorted(loopDict.keys()):
            justIndex = []
            for v in loopDict[edge]:
                justIndex.append(v.index())
            justIndexDict[edge] = justIndex

        for edge in sorted(justIndexDict.keys()):
            if int(edge) + 1 >= len(justIndexDict):
                continue
            if deleted:
                currHair = pym.PyNode(newHair)

            hairShape = currHair.getShape().name()
            hairName = currHair.name()

            firstLoop = []
            secondLoop = []
            for vtx in justIndexDict[edge]:
                firstLoop.append(pym.MeshVertex(currHair, vtx))

            for vtx in justIndexDict['{:04d}'.format(int(edge) + 1)]:
                secondLoop.append(pym.MeshVertex(currHair, vtx))

            pym.select(firstLoop + secondLoop)

            cmds.ConvertSelectionToContainedFaces()
            cmds.polyChipOff(ch=1, kft=1, dup=1, off=0)

            hairPieces = cmds.polySeparate(hairShape, rs=1, ch=1)

            for i in hairPieces:
                cmds.DeleteHistory(i)

            cmds.parent(hairPieces[1], hairChunksGRP)
            cmds.rename(hairPieces[1], "{0}_piece_{1}".format(hairName, edge))

            deletable, = cmds.listRelatives(hairPieces[0], p=1)
            cmds.parent(hairPieces[0], w=1)

            cmds.delete(deletable)
            newHair = cmds.rename(hairPieces[0], hairName)
            deleted = True

        return hairChunksGRP, newHair
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")
Example #24
0
 def _snap_control(self, control, group, target):
     """
     Handles snapping controls.
     """
     snap_tuple = (control, group)
     # snap the control
     for obj in snap_tuple:
         tmp_constraint = cmds.parentConstraint(target, obj)
         cmds.delete(tmp_constraint)
     cmds.parent(control, group)
     cmds.makeIdentity(control, apply=True)
     cmds.DeleteHistory(control)
Example #25
0
def fLMImport(arg):

    path = mc.textField(
        'fLMtextField',
        q=True,
        fi=True,
    )
    if path.find('.obj') < 0:
        mc.error('select OBJ mesh')
    else:
        flbelist = mc.ls(type="transform")
        mc.file(path,
                i=True,
                type="OBJ",
                ra=True,
                mergeNamespacesOnClash=True,
                namespace="OrigFolded",
                options="mo=1,lo=0")
        flaflist = mc.ls(type="transform")
        #seperate pieces
        origFLMlist_root = list(set(flaflist) - set(flbelist))
        origFLMlist_temp = []
        origFLMlist = []
        for flm in origFLMlist_root:
            mc.select(flm)
            mc.SeparatePolygon()
            mc.DeleteHistory()
            flsep_list = []
            flsep_templist = mc.ls(sl=True)
            for flsep in flsep_templist:
                mc.select(flsep)
                flsep_list.append(mc.rename('OrigFolded_01'))
            mc.pickWalk(direction='up')
            mc.Ungroup()
            origFLMlist_temp.append(flsep_list)
        for x in origFLMlist_temp:
            for y in x:
                origFLMlist.append(y)

        #create Set for original folded mesh hide
        if mc.objExists('OrigFoldMeshes_set'):
            mc.sets(origFLMlist, forceElement='OrigFoldMeshes_set')
        else:
            newSet1 = cmds.sets(name='OrigFoldMeshes_set')
            mc.sets(origFLMlist, forceElement='OrigFoldMeshes_set')
            #hide Original mesh accordingly if check box is on or off KEISTI!!!!!!!!!!!!!
            mc.select('OrigFoldMeshes_set')
            listObjectsInSet = mc.ls(sl=True)
            for objOnSet in listObjectsInSet:
                visValue = mc.getAttr(str(objOnSet) + '.visibility')
                checkBoxStatus = mc.checkBox('fLMOrigCheckBox', q=True, v=True)
                if visValue is False or checkBoxStatus is True:
                    mc.setAttr((objOnSet + '.visibility'), 0)
Example #26
0
 def mainCtrls(self):
     self.strMaster = mm.eval(
         "curve -d 1 -p -1 0 -1 -p -1 0 -5 -p -2 0 -5 -p 0 0 -7 -p 2 0 -5 -p 1 0 -5 -p 1 0 -1 -p 5 0 -1 -p 5 0 -2 -p 7 0 0 -p 5 0 2 -p 5 0 1 -p 1 0 1 -p 1 0 5 -p 2 0 5 -p 0 0 7 -p -2 0 5 -p -1 0 5 -p -1 0 1 -p -5 0 1 -p -5 0 2 -p -7 0 0 -p -5 0 -2 -p -5 0 -1 -p -1 0 -1 -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 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 "
     )
     self.strMaster = mc.rename(self.strMaster, 'Master')
     self.strMasterGrp = mc.group(self.strMaster, n='Master_GRP')
     self.strWorld = mc.circle(r=7, nr=(0, 1, 0), n='World')
     mc.DeleteHistory()
     self.strWorldGrp = mc.group(self.strWorld[0], n='RIG')
     mc.parent(self.strMasterGrp, self.strWorld[0])
     masterShape = mc.listRelatives(self.strMaster, s=1)[0]
     mc.setAttr(masterShape + '.overrideEnabled', 1)
     mc.setAttr(masterShape + '.overrideColor', 17)
Example #27
0
def clusterFuck(obj):
    grp = mc.spaceLocator()
    clusters = mc.listConnections(obj, type='skinCluster')
    for cluster in clusters:
        joints = mc.listConnections(cluster, type='joint')
        for joint in joints:
            joint = joint.replace(':', '__')
            mc.select(obj)
            dupe = mc.duplicate(rr=1, name=joint)
            mc.parent(world=True)
            mc.DeleteHistory()
            print grp
            mc.parent(dupe, grp)
Example #28
0
def create_finger_tweaker(obj_name):
    """
    creates a finger tweaker shape

    :param obj_name: what to name the tweaker
    :type: str
    """
    # makes and moves a circle a little bit off origin
    circ = cmds.circle(center=[0, 0, 0],
                       normal=[1, 0, 0],
                       sweep=360,
                       radius=.5,
                       degree=3,
                       useTolerance=0,
                       tolerance=0,
                       sections=8,
                       caching=1)[0]
    cmds.select(circ + '.cv[0:7]')
    cmds.xform(translation=[0, 2, 0], relative=True)
    cmds.xform(absolute=True, worldSpace=True, pivots=[0, 0, 0])
    cmds.makeIdentity(circ,
                      apply=True,
                      translate=True,
                      rotate=True,
                      scale=True,
                      normal=False,
                      preserveNormals=1)
    # cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0, pn=1)

    # makes a line from origin to circle
    line = cmds.curve(degree=1, point=[(0, 0, 0), (0, 1.5, 0)], knot=[0, 1])

    # gets the shape nodes of the line and circle
    shapes = cmds.listRelatives([circ, line], shapes=True)

    # creates an empty group and parents the shape nodes to it
    grp = cmds.group(empty=True, name=obj_name)
    cmds.parent(shapes, grp, add=True, shape=True, relative=True)

    cmds.delete(circ, line)
    #clear history
    cmds.select(obj_name)
    cmds.DeleteHistory()

    # adds the globabl attr
    cmds.addAttr('|' + obj_name,
                 longName=NamingConventionEnums.GLOBAL_ATTR_NAME,
                 attributeType='bool')
Example #29
0
def random_spawner(amount, grow_flag, move_range, scale_lower, scale_upper):
    spawn_num = 1
    duplicates = list()
    selection = cmds.ls(sl=True)
    polygons = cmds.filterExpand(selection, sm=12)
    if len(polygons) > 1:
        poly = cmds.polyUnite(polygons)
    else:
        poly = polygons
    cmds.rename(poly[0], 'Spawn_' + str(spawn_num))
    duplicates.append('Spawn_' + str(spawn_num))
    polygons[0] = 'Spawn_' + str(spawn_num)
    cmds.DeleteHistory((polygons[0]))
    cmds.xform('Spawn_' + str(spawn_num), pivots=(0, 0, 0), ws=True)
    if grow_flag:
        i = 0
        while i < amount:
            polygon = cmds.duplicate('Spawn_' + str(spawn_num))
            cmds.rename(polygon[0], 'CurrentSpawn')
            current_position = cmds.xform('CurrentSpawn', ws=True, query=True, translation=True)
            move_adj_x = (random.randrange(-1000 * move_range, 1000 * move_range)) / 1000
            move_adj_z = (random.randrange(-1000 * move_range, 1000 * move_range)) / 1000
            x = current_position[0] + move_adj_x
            y = current_position[1]
            z = current_position[2] + move_adj_z
            scale_adj = (random.randrange(1000 * scale_lower, 1000 * scale_upper)) / 1000
            cmds.scale(scale_adj, scale_adj, scale_adj, 'CurrentSpawn')
            cmds.move(x, y, z, 'CurrentSpawn')
            spawn_num += 1
            cmds.rename('CurrentSpawn', 'Spawn_' + str(spawn_num))
            duplicates.append('Spawn_' + str(spawn_num))
            i += 1
    else:
        i = 0
        while i < amount:
            polygon = cmds.duplicate('Spawn_' + str(spawn_num))
            cmds.rename(polygon[0], 'CurrentSpawn')
            x = (random.randrange(-1000 * move_range, 1000 * move_range)) / 1000
            z = (random.randrange(-1000 * move_range, 1000 * move_range)) / 1000
            scale_adj = (random.randrange(1000 * scale_lower, 1000 * scale_upper)) / 1000
            cmds.scale(scale_adj, scale_adj, scale_adj, 'CurrentSpawn')
            cmds.move(x, 0, z, 'CurrentSpawn', ws=True)
            spawn_num += 1
            cmds.rename('CurrentSpawn', 'Spawn_' + str(spawn_num))
            duplicates.append('Spawn_' + str(spawn_num))
            i += 1
    cmds.group(duplicates, name='Geometry')
Example #30
0
def auto_rig_parent_constraint(copy_cntrl):
    """
    This function takes a given curve and copies + connects it with (parent-constraint) list of objects.

    :copy_cntrl: cntrl that should be copied + connect with all objects within the object_list
    :return:
    """
    selection = cmds.ls(selection=True)
    object_list = cmds.listRelatives(selection, allDescendents=True)

    for object in object_list:
        cntrl = cmds.duplicate(copy_cntrl)
        point_constraint = cmds.pointConstraint(object, cntrl)
        cmds.delete(point_constraint)
        cmds.makeIdentity(cntrl, apply=True, translate=True)
        cmds.DeleteHistory(cntrl)
        cmds.parentConstraint(cntrl, object, maintainOffset=True)