def Cnvert_BTN_Fun(self):
        sel = cmds.ls(sl=True, fl=True)

        for obj in sel:

            shapeNode = cmds.listRelatives(obj, children=True, shapes=True)

            SGNodeList = cmds.listConnections(shapeNode[0],
                                              type="shadingEngine")

            SGNodeList = list(set(SGNodeList))

            for SGNode in SGNodeList:

                shader = cmds.listConnections(SGNode + ".surfaceShader")

                cmds.select(cl=True)

                cmds.hyperShade(objects=shader[0])

                cmds.ConvertSelectionToFaces()

                faceList = cmds.ls(sl=True, fl=True)

                cmds.sets(cl=(shader[0] + "SG"))

                for face in faceList:
                    if obj == face.split('.')[0]:
                        cmds.select(face)
                        cmds.sets(add=(shader[0] + "SG"))

        mel.eval("maintainActiveChangeSelectMode " + sel[-1] + ";")
        cmds.select(cl=True)
        cmds.headsUpMessage(u'转换成功')
        self.Save_Json_Fun()
Example #2
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 #3
0
    def rebind(self):
        components = self.components_to_rebind.text().split()
        faces = self.target_faces.text().split()
        wrap_node = self.cvwrap_combo.currentText()
        radius = self.sample_radius.value()
        # Make sure the faces are actual faces.  If they are not, convert to faces.
        cmds.select(faces)
        cmds.ConvertSelectionToFaces()
        faces = cmds.ls(sl=True)

        cmds.select(components)
        cmds.ConvertSelectionToVertices()
        cmds.select(faces, add=True)
        cmds.cvWrap(rb=wrap_node, radius=radius)
        print 'Rebounded vertices'
Example #4
0
def UVoverlap(*args):
    global selection
    global display8, UVolface
    cmds.select(selection)
    NameList_Uvoverlap = []
    cmds.ConvertSelectionToFaces()
    UVolface = cmds.polyUVOverlap(oc=True)
    cmds.select(UVolface)
    cmds.ConvertSelectionToShell()
    NameList = cmds.ls(sl=True)
    cmds.select(clear=1)
    cmds.hilite(replace=True)
    print UVolface
    for i in NameList:
        NameList_Uvoverlap.append(i.split('.')[0].encode('utf8'))
    if len(NameList_Uvoverlap) != 0:
        display8 = 1
    return NameList_Uvoverlap
Example #5
0
def unwrapCylindrical():
    # Variables and selection
    mode = cmds.radioButtonGrp('mode', q=True, select=True)
    seam = cmds.ls(sl=True)

    cmds.SelectEdgeRingSp()
    cmds.ConvertSelectionToContainedFaces()

    body = cmds.ls(sl=True)

    # Chooses desired seams
    numEdges = (len(seam))
    if (numEdges == 1):
        seamSel = (seam[0])
    else:
        seamSel = (seam[0:numEdges])

    bodySel = (body[0:(len(body))])

    # Unwraps with or without unfolding

    if (mode == 1):
        cmds.polyPlanarProjection()
        cmds.select(seamSel, r=True)
        cmds.polyMapCut()
        cmds.unfold()

    elif (mode == 2):
        cmds.select(bodySel, r=True)
        cmds.ConvertSelectionToFaces()
        shell = cmds.ls(sl=True)
        cmds.polyForceUV(unitize=True)

        cmds.ConvertSelectionToContainedEdges()

        cmds.select(seamSel, d=True)
        cmds.polyMapSewMove()
        cmds.select(shell, r=True)
        cmds.ConvertSelectionToUVs()
        cmds.polyLayoutUV()
        cmds.select(shell, r=True)
def checkTdStart(self):

    global td_control,offset_control,tsize_control;
    tsize=cmds.intField(tsize_control,q=True, v=True);
    td=cmds.floatField(td_control,q=True, v=True);
    offset=cmds.floatField(offset_control,q=True, v=True);
    
    cmds.ConvertSelectionToFaces();
    cmds.ls(sl=True,long=True) or []
    selected = cmds.filterExpand( sm=34 );
    
    if selected is None or len(selected) <=0 :
        MessageBox("未选中对象!");
        return;
    
    r=[];
    texSize = tsize*tsize;
    for f in selected:
        fa = getFaceTexelDensity(f,texSize);
        if abs(fa-td)>offset:
            r.append(f);
    cmds.select(cl=True);
    cmds.select(r);
    MessageBox(" 选中 %d 个面" % len(r))
Example #7
0
def convFaces(*args):
    '''
	Convert to Faces
	'''
    cmds.ConvertSelectionToFaces()
Example #8
0
    def Close(self, btn):
        cmds.deleteUI(self.msg)


def NormalAction(fs):
    for f in fs:
        node = f.split('.')[0]
        pi = cmds.polyInfo(f, fn=True)
        vss = cmds.polyInfo(f, fv=True)
        fn = re.findall(r"[\w.-]+", pi[0])
        # convert the string to array with regular expression
        vssre = re.findall(r"[\w]+", vss[0])

        vs = []

        for index in range(2, len(vssre)):
            vs.append("{0}.vtx[{1}]".format(node, vssre[index]))

        cmds.select(vs, r=True)
        cmds.polyNormalPerVertex(xyz=(float(fn[2]), float(fn[3]),
                                      float(fn[4])))


cmds.ConvertSelectionToFaces()
fs = cmds.filterExpand(sm=34)

if fs is None:
    MessageBox("δѡÖÐÃ棡")
else:
    NormalAction(fs)
Example #9
0
def selFace(*args):
	cmds.ConvertSelectionToFaces()