Python maya.cmds.polyListComponentConversion() Examples

The following are 6 code examples of maya.cmds.polyListComponentConversion(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: common.py    From SIWeightEditor with MIT License 6 votes vote down vote up
def conv_comp(obj, mode=''):
    if mode == 'edge':
        comp = cmds.polyListComponentConversion(obj, te=True)
        comp = cmds.filterExpand(comp, sm=32)
    if mode == 'face':
        comp = cmds.polyListComponentConversion(obj, tf=True)
        comp = cmds.filterExpand(comp, sm=34)
    if mode == 'vtx':
        comp = cmds.polyListComponentConversion(obj, tv=True)
        comp = cmds.filterExpand(comp, sm=31)
    if mode == 'uv':
        comp = cmds.polyListComponentConversion(obj, tuv=True)
        comp = cmds.filterExpand(comp, sm=35)
    if mode == 'vf':
        comp = cmds.polyListComponentConversion(obj, tvf=True)
        comp = cmds.filterExpand(comp, sm=70)
    return comp 
Example #2
Source File: uv.py    From SISideBar with MIT License 5 votes vote down vote up
def copy_uv(self):
        sel = cmds.ls(sl=True, l=True)
        self.copy_uvs = cmds.polyListComponentConversion(sel, tuv=True)
        self.copy_uvs = cmds.filterExpand(self.copy_uvs, sm=35)
        if self.copy_uvs:
            save_uv_data = {'copy_uv':self.copy_uvs }
            with open(self.saveFile, 'w') as f:
                json.dump(save_uv_data, f) 
Example #3
Source File: modeling.py    From SISideBar with MIT License 5 votes vote down vote up
def cehck_zero_poly_object(mesh=None, pop_msg=True):
    #mesh 入力メッシュ
    #pop_msg 探索結果を表示するかどうか
    if mesh == None:
        polyMeshes = common.search_polygon_mesh(cmds.ls(tr=True))
    else:
        polyMeshes = common.search_polygon_mesh(mesh)
    zeroPolyObj = []
    if polyMeshes == None:
        if pop_msg:
            cmds.confirmDialog( title="Check",message='Zero Polygon Object Count :  0')
        return zeroPolyObj
    for p in polyMeshes:
        vtx = cmds.polyListComponentConversion(p, tv=True)
        if vtx == []:
            zeroPolyObj.append(p)
    if not pop_msg:
        return zeroPolyObj
    if zeroPolyObj == []:
        cmds.confirmDialog( title="Check",message='Zero Polygon Object Count :  0')
    else:
        msg = 'Zero Polygon Object Count : '+str(len(zeroPolyObj))
        for p in zeroPolyObj:
            msg+='\n[ '+p+' ]'
        cmds.confirmDialog( title="Check",message=msg )
        cmds.select(zeroPolyObj, r=True)
    return zeroPolyObj
    
#スキニングを保ったままメッシュマージする関数 
Example #4
Source File: common.py    From SISideBar with MIT License 5 votes vote down vote up
def conv_comp(obj, mode=''):
    if mode == 'edge':
        comp = cmds.polyListComponentConversion(obj, te=True)
        comp = cmds.filterExpand(comp, sm=32)
    if mode == 'face':
        comp = cmds.polyListComponentConversion(obj, tf=True)
        comp = cmds.filterExpand(comp, sm=34)
    if mode == 'vtx':
        comp = cmds.polyListComponentConversion(obj, tv=True)
        comp = cmds.filterExpand(comp, sm=31)
    if mode == 'uv':
        comp = cmds.polyListComponentConversion(obj, tuv=True)
        comp = cmds.filterExpand(comp, sm=35)
    return comp 
Example #5
Source File: modeling.py    From SIWeightEditor with MIT License 5 votes vote down vote up
def cehck_zero_poly_object(mesh=None, pop_msg=True):
    #mesh 入力メッシュ
    #pop_msg 探索結果を表示するかどうか
    if mesh == None:
        polyMeshes = common.search_polygon_mesh(cmds.ls(tr=True))
    else:
        polyMeshes = common.search_polygon_mesh(mesh)
    zeroPolyObj = []
    if polyMeshes == None:
        if pop_msg:
            cmds.confirmDialog( title="Check",message='Zero Polygon Object Count :  0')
        return zeroPolyObj
    for p in polyMeshes:
        vtx = cmds.polyListComponentConversion(p, tv=True)
        if vtx == []:
            zeroPolyObj.append(p)
    if not pop_msg:
        return zeroPolyObj
    if zeroPolyObj == []:
        cmds.confirmDialog( title="Check",message='Zero Polygon Object Count :  0')
    else:
        msg = 'Zero Polygon Object Count : '+str(len(zeroPolyObj))
        for p in zeroPolyObj:
            msg+='\n[ '+p+' ]'
        cmds.confirmDialog( title="Check",message=msg )
        cmds.select(zeroPolyObj, r=True)
    return zeroPolyObj
    
#スキニングを保ったままメッシュマージするクラス 
Example #6
Source File: uv.py    From SISideBar with MIT License 4 votes vote down vote up
def paste_uv(self, mode='component'):
        if os.path.exists(self.saveFile):
            with open(self.saveFile, 'r') as f:
                save_uv_data = json.load(f)
            self.copy_uvs = save_uv_data['copy_uv']
        else:
            return
        sel = cmds.ls(sl=True, l=True)
        self.paste_uvs = cmds.polyListComponentConversion(sel, tuv=True)
        self.paste_uvs = cmds.filterExpand(self.paste_uvs, sm=35)
        cmds.select(self.paste_uvs, r=True)
        cmds.selectMode(o=True)
        target_obj = [obj.split('.')[0] for obj in cmds.ls(sl=True, l=True)]
        #print 'get target :', target_obj
        freeze_m.main(mesh=target_obj)
        if not self.paste_uvs:
            return
        paste_objects = list(set([uv.split('.')[0] for uv in self.paste_uvs]))
        #cmds.bakePartialHistory(paste_objects, pre=True)
        #print paste_objects
        paste_uvs_dict = {obj:[] for obj in paste_objects}
        #print paste_uvs_dict
        for uv in map(lambda uv:uv.split('.'), self.paste_uvs):
            paste_uvs_dict[uv[0]] += ['.'.join(uv)]
        #print paste_uvs_dict
        for paste_uvs in paste_uvs_dict.values():
            #print paste_uvs
            cmds.select(cl=True)
            cmds.select(self.copy_uvs, r=True)
            cmds.select(paste_uvs, add=True) 
            if mode == 'component':
                sample_space = 4 
            if mode == 'world':
                sample_space = 0
            #print mode
            cmds.transferAttributes(flipUVs=0, transferPositions=0, transferUVs=2, searchMethod=3, 
                                                transferNormals=0, transferColors=0, colorBorders=1, sampleSpace=sample_space)

        freeze_m.main(mesh=target_obj)
        cmds.select(target_obj, r=True) 

#UVセットをリネーム、マルチUVの削除など