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)
Ejemplo n.º 2
0
def main():
    sel = cmds.ls(sl=True, fl=True, long=True)
    for i in sel:
        edges = selectTextureBorderEdges(i)
        cmds.select(edges, r=True)
        cmds.DetachEdgeComponent(edges)
        cmds.select(i, r=True)
        cmds.SeparatePolygon()

    cmds.select(sel, r=True)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def _separatePolygons(self):
     cmds.SeparatePolygon()
Ejemplo n.º 5
0
def sep(*args):
    '''
	Seperates polygon objects
	'''
    cmds.SeparatePolygon()
Ejemplo n.º 6
0
def separatePolygons():
    cmds.SeparatePolygon()
Ejemplo n.º 7
0
def fMImport_Retopo(arg):

    path = mc.textField(
        'fMtextField',
        q=True,
        fi=True,
    )
    if path.find('.obj') < 0:
        mc.error('select OBJ mesh')
    else:
        belist = mc.ls(type="transform")
        test = mc.file(path,
                       i=True,
                       type="OBJ",
                       ra=True,
                       mergeNamespacesOnClash=True,
                       namespace="OrigFlatten",
                       options="mo=1,lo=0")
        aflist = mc.ls(type="transform")
        #seperate pieces
        origFMlist_root = list(set(aflist) - set(belist))
        origFMlist_temp = []
        origFMlist = []
        for fm in origFMlist_root:
            mc.select(fm)
            mc.SeparatePolygon()
            mc.DeleteHistory()
            sep_list = []
            sep_templist = mc.ls(sl=True)
            for sep in sep_templist:
                mc.select(sep)
                sep_list.append(mc.rename('OrigFlatten_01'))
            mc.pickWalk(direction='up')
            mc.Ungroup()
            origFMlist_temp.append(sep_list)
        for x in origFMlist_temp:
            for y in x:
                origFMlist.append(y)

        #create set or add into existing one original flatten mesh
        if mc.objExists('OrigFlatMeshes_set'):
            mc.sets(origFMlist, forceElement='OrigFlatMeshes_set')
        else:
            newSet1 = cmds.sets(name='OrigFlatMeshes_set')
            mc.sets(origFMlist, forceElement='OrigFlatMeshes_set')
        #polyRetopo imported meshes
        pRlist = []
        for u in origFMlist:
            mc.select(u)
            mc.ConvertSelectionToEdgePerimeter(u)
            mc.planarSrf(
                n='Surface' +
                str(u))  # reikia variable pavadinima ivesti jog sukurtu
            mc.nurbsToPoly(ch=True,
                           f=0,
                           pt=1,
                           pc=1000,
                           chr=0.9,
                           ft=0.01,
                           mel=0.001,
                           d=0.1,
                           n='nurbsToPoly' + str(u))
            chpoly = mc.polyEvaluate(shell=True)
            #check if mesh has several pieces
            if chpoly > 1:
                mc.SeparatePolygon()
            mc.DeleteHistory()
            chlist = mc.ls(sl=True)
            #check if mesh is in the group
            if len(chlist) > 1:
                mc.pickWalk(direction='up')
                mc.Ungroup()
            o = mc.ls(sl=True)
            if len(o) == 1:
                mc.polyRetopo('nurbsToPoly' + str(u))
                mc.rename('Retopo_mesh_01')
                #add new polyRetopo mesh to list
                pRsl = mc.ls(sl=True)
                pRlist.append(pRsl)
            else:
                for y in o:
                    mc.select(y, r=True)
                    mc.polyRetopo(y)
                    mc.sets(fe='initialShadingGroup')
                    mc.rename('Retopo_mesh_01')
                    #add new polyRetopo mesh to list
                    pRsl = mc.ls(sl=True)
                    pRlist.append(pRsl)

            sfrlist = mc.select('Surface' + str(u))
            mc.Delete(sfrlist)
            #hide Original mesh accordingly if check box is on or off
            mc.select('OrigFlatMeshes_set')
            listObjectsInSet = mc.ls(sl=True)
            for objOnSet in listObjectsInSet:
                visValue = mc.getAttr(str(objOnSet) + '.visibility')
                checkBoxStatus = mc.checkBox('fMOrigCheckBox', q=True, v=True)
                if visValue is False or checkBoxStatus is True:
                    mc.setAttr((objOnSet + '.visibility'), 0)
        #transfer uvs from Marvelous mesh to new polyRetopo meshes
        iterpRlist = iter(pRlist)
        for fm in origFMlist:
            mc.select(fm)
            mc.select(next(iterpRlist), add=True)
            mc.transferAttributes(transferPositions=0,
                                  transferNormals=0,
                                  transferUVs=2,
                                  transferColors=0,
                                  sampleSpace=0,
                                  sourceUvSpace="map1",
                                  targetUvSpace="map1",
                                  searchMethod=3,
                                  flipUVs=0,
                                  colorBorders=1)
        #adapt faceCount of new created polyRetopo meshes
        mc.select(d=True)
        for pRmesh in pRlist:
            mc.select(pRmesh, add=True)
        adaptPoly()
Ejemplo n.º 8
0
def m_polyretopo():

    selected = mc.ls(sl=True)
    pRlist = []
    #create set or add into existing one original flatten mesh
    if mc.objExists('OrigFlatMeshes_set'):
        mc.sets(selected, forceElement='OrigFlatMeshes_set')
    else:
        newSet1 = cmds.sets(name='OrigFlatMeshes_set')
        mc.sets(selected, forceElement='OrigFlatMeshes_set')
    for u in selected:
        mc.select(u)
        mc.ConvertSelectionToEdgePerimeter(u)
        mc.planarSrf(n='Surface' +
                     str(u))  # reikia variable pavadinima ivesti jog sukurtu
        mc.nurbsToPoly(ch=True,
                       f=0,
                       pt=1,
                       pc=1000,
                       chr=0.9,
                       ft=0.01,
                       mel=0.001,
                       d=0.1,
                       n='nurbsToPoly' + str(u))
        chpoly = mc.polyEvaluate(shell=True)
        #check if mesh has several pieces
        if chpoly > 1:
            mc.SeparatePolygon()
        mc.DeleteHistory()
        chlist = mc.ls(sl=True)
        #check if mesh is in the group
        if len(chlist) > 1:
            mc.pickWalk(direction='up')
            mc.Ungroup()
        o = mc.ls(sl=True)
        if len(o) == 1:
            mc.polyRetopo('nurbsToPoly' + str(u))
            mc.rename('Retopo_mesh_01')
            #add new polyRetopo mesh to list
            pRsl = mc.ls(sl=True)
            pRlist.append(pRsl)
        else:
            for y in o:
                mc.select(y, r=True)
                mc.polyRetopo(y)
                mc.sets(fe='initialShadingGroup')
                mc.rename('Retopo_mesh_01')
                #add new polyRetopo mesh to list
                pRsl = mc.ls(sl=True)
                pRlist.append(pRsl)

        sfrlist = mc.select('Surface' + str(u))
        mc.Delete(sfrlist)
        #hide Original mesh accordingly if check box is on or off
        mc.select('OrigFlatMeshes_set')
        listObjectsInSet = mc.ls(sl=True)
        for objOnSet in listObjectsInSet:
            visValue = mc.getAttr(str(objOnSet) + '.visibility')
            checkBoxStatus = mc.checkBox('fMOrigCheckBox', q=True, v=True)
            if visValue is False or checkBoxStatus is True:
                mc.setAttr((objOnSet + '.visibility'), 0)