Пример #1
0
def multi_polyQuad():
    args,counter = pm.ls(sl=True),1
    w=400
    window = pm.window(w=w,h=40)
    pm.columnLayout()
    progressMessage=pm.text(l='Running through Objects...',w=w)
    argName=pm.text(l='',w=w)
    progressControl = pm.progressBar(isInterruptable=True, beginProgress=True, maxValue=len(args), width=w)
    window.show()
    for arg in args:
        if pm.progressBar(progressControl, query=True, isCancelled=True ) :
            break
        progressMessage.setLabel('Cleaning up then Quadding object '+str(counter)+'/'+str(len(args))+':')
        argName.setLabel(arg)
        pm.select(arg,r=True)
        #cleanup mesh
        mel.eval('polyCleanupArgList 3 { "0","1","0","0","0","0","0","0","0","1e-05","0","1e-05","0","1e-05","0","1","0" };')
        #quad all polies
        pm.polyQuad(arg, a=30, kgb=False, ktb=False,khe=False,ws=True,ch=False)
        #merge all verts
        pm.polyMergeVertex((arg+'.vtx[0:'+str(pm.polyEvaluate(arg,v=True))+']'), d=.001,am=True,ch=0)
        pm.polyNormalPerVertex(arg,ufn=True)
        pm.polySoftEdge(arg,angle=68, ch=0)
        pm.progressBar(progressControl, edit=True, step=1)
        counter+=1
    pm.progressBar(progressControl, edit=True, endProgress=True)
    pm.select(args, r=True)
    pm.selectMode(o=True)
    window.delete()
Пример #2
0
 def marge_run(self):
     objects = common.search_polygon_mesh(self.objects, serchChildeNode=True, fullPath=True)
     #print('marge target :', objects)
     if len(objects) < 2:
         self.marged_mesh = objects
         return True
     skined_list = []
     no_skin_list = []
     parent_list = [cmds.listRelatives(obj, p=True, f=True) for obj in objects]
     
     for obj in objects:
         skin = cmds.ls(cmds.listHistory(obj), type='skinCluster')
         if skin:
             skined_list.append(obj)
         else:
             no_skin_list.append(obj)
             
     if no_skin_list and skined_list:
         skined_mesh = skined_list[0]
         for no_skin_mesh in no_skin_list:
             weight.transfer_weight(skined_mesh, no_skin_mesh, transferWeight=False, returnInfluences=False, logTransfer=False)
             
     if skined_list:
         marged_mesh = pm.polyUniteSkinned(objects)[0]
         pm.polyMergeVertex(marged_mesh, d=0.001)
         target_mesh = pm.duplicate(marged_mesh)[0]
         weight.transfer_weight(str(marged_mesh), str(target_mesh), transferWeight=True, returnInfluences=False, logTransfer=False)
     else:
         marged_mesh = pm.polyUnite(objects, o=True)[0]
         pm.polyMergeVertex(marged_mesh, d=0.001)
         target_mesh = pm.duplicate(marged_mesh)[0]
         #pm.delete(objects)
     for obj in objects:
         if pm.ls(obj):
             pm.delete(obj)
         
     pm.delete(marged_mesh)
     
     all_attr_list = [['.sx', '.sy', '.sz'], ['.rx', '.ry', '.rz'], ['.tx', '.ty', '.tz']]
     for p_node in parent_list:
         if cmds.ls(p_node, l=True):
             all_lock_list = []
             for attr_list in all_attr_list:
                 lock_list = []
                 for attr in attr_list:
                     lock_list.append(pm.getAttr(target_mesh+attr, lock=True))
                     pm.setAttr(target_mesh+attr, lock=False)
                 all_lock_list.append(lock_list)
             pm.parent(target_mesh, p_node[0])
             for lock_list, attr_list in zip(all_lock_list, all_attr_list):
                 for lock, attr in zip(lock_list, attr_list):
                     #continue
                     #print('lock attr :', lock, target_mesh, attr)
                     pm.setAttr(target_mesh+attr, lock=lock)
             break
     pm.rename(target_mesh, objects[0])
     pm.select(target_mesh)
     self.marged_mesh = str(target_mesh)
     return True
Пример #3
0
 def merge_and_weld(cls, polyList=None, *args, **kwargs):
     '''
     merge and weld items from a list, or if empty selection
     '''
     if not polyList:
         polyList = pm.ls(sl=True)
     if len(polyList) > 1:
         merged = pm.PyNode(pm.polyUnite(polyList)[0])
         pm.polyMergeVertex(merged, distance=0.001)
         pm.delete(merged, constructionHistory=True)
     else:
         lcUtility.Utility.lc_print('Select 2 or more polygon objects', mode='warning')
Пример #4
0
def uvmp_merge_special(*args, **kwargs):
    '''
    merge with a very close distance
    '''

    sel = pm.ls(sl=True)
    if sel:
        pm.polyMergeVertex(sel, distance=0.001)
        pm.delete(sel, constructionHistory=True)
        pm.polySoftEdge(sel, a=180)
        pm.select(sel, replace=True)
    else:
        lcUtility.Utility.lc_print('Please select one or more objects',
                                   mode='warning')
Пример #5
0
def mergeCenterEdgeIslands(edges):
	'''
	Args:
		edges (list(pm.nt.general.MeshEdge)): edges to be clustered
	Returns (list(pm.nt.Transform)): list of cluster transforms 
	Usage:
		islands = mergeCenterEdgeIslands(pm.ls(sl=True,fl=True))
	'''
	islands = getEdgeIslands(edges)
	for island in islands:
		
		islandVerts = pm.ls( pm.polyListComponentConversion(island, tv=True), fl=True )
		pm.select(islandVerts, r=True)
		pm.polyMergeVertex( islandVerts, d=1, am=True, mtc=True )
	return islands
Пример #6
0
    def ec_face_mirror(self, **kwargs):
        attr = kwargs.setdefault('axis', 'sx')
        if self.gui is True:
            obj = py.textField('nameText', q=True, tx=True)
        else:
            obj = kwargs.setdefault('obj')
        sel = py.ls(sl=True)
        py.polyChipOff(sel, dup=True)
        temp_obj = py.polySeparate(obj, n='tempObj')

        py.setAttr('%s.%s' % (temp_obj[1], attr), -1)
        py.select(temp_obj)
        temp_obj[0] = py.polyUnite(temp_obj, ch=False)
        py.rename(temp_obj[0], obj)
        mel.eval('ConvertSelectionToVertices;')
        py.polyMergeVertex()
Пример #7
0
def combineClean(instanceGroup, meshName, duplicateFaces=False):

    print("Combining mesh")

    mesh = pm.polyUnite(instanceGroup,
                        name=meshName,
                        constructionHistory=False)

    #print( "Merging %i" % len( mesh[ 0 ].vtx ) + " verticies" )
    pm.polyMergeVertex(mesh[0].vtx, distance=0.1)
    #print( "Reduced to %i" % mesh[ 0 ].numVertices() + " verticies" )

    if duplicateFaces:

        print("Cleaning up faces")

        pm.select(mesh[0])
        pm.selectType(polymeshFace=True)
        pm.polySelectConstraint(mode=3, type=0x0008, topology=2)

        # Don't ask me how I did this

        mel.eval(
            'polyCleanupArgList 3 { "0","2","0","0","0","0","0","0","0","1e-005","0","1e-005","1","0.3","0","-1","1" };'
        )

        pm.delete()
        pm.polySelectConstraint(mode=0, topology=0)
        pm.selectType(polymeshFace=False)
        pm.selectMode(object=True)

        print("Faces reduced")

    if pm.PyNode(instanceGroup).exists():

        pm.delete(instanceGroup)

    pm.delete(constructionHistory=True)
    pm.select(clear=True)

    print("Cleaning up complete")

    return mesh
Пример #8
0
def combineClean( instanceGroup, meshName, duplicateFaces = False ):
            
    print( "Combining mesh" )
    
    mesh = pm.polyUnite( instanceGroup, name = meshName, constructionHistory = False )

    #print( "Merging %i" % len( mesh[ 0 ].vtx ) + " verticies" )
    pm.polyMergeVertex( mesh[ 0 ].vtx, distance = 0.1 )
    #print( "Reduced to %i" % mesh[ 0 ].numVertices() + " verticies" )

    if duplicateFaces:

        print( "Cleaning up faces" )

        pm.select( mesh[ 0 ] )
        pm.selectType( polymeshFace = True )
        pm.polySelectConstraint( mode = 3, type = 0x0008, topology = 2 )
        
        # Don't ask me how I did this

        mel.eval('polyCleanupArgList 3 { "0","2","0","0","0","0","0","0","0","1e-005","0","1e-005","1","0.3","0","-1","1" };') 
        
        pm.delete()
        pm.polySelectConstraint( mode = 0, topology = 0 ) 
        pm.selectType( polymeshFace = False )   
        pm.selectMode( object = True )

        print( "Faces reduced" )      


    if pm.PyNode( instanceGroup ).exists():
        
        pm.delete( instanceGroup )


    pm.delete( constructionHistory = True )
    pm.select( clear = True )
    
    print( "Cleaning up complete" )

    return mesh
Пример #9
0
    def createShape(self, i_isGroup, i_mesh):
        """create voxels
           Keyword arguments:
           i_isGroup: if the result is one object or each voxel seperated
           i_mesh: the voxel
        """
        distanceLimit = math.sqrt(self._voxelSize*self._voxelSize*3)
        for p in self._voxelsPosList:
            r = self._oriMdl.getClosestPointAndNormal((p[0], p[1], p[2]))
            closestPoint = r[0] + self._oriMdl.getTranslation()
            
            # when the cube is far from the surface
            if distanceLimit < getLength((p[0]-closestPoint[0], 
                                          p[1]-closestPoint[1], 
                                          p[2]-closestPoint[2])):
                continue
            
            dp = dotProduct(normalize([p[0]-closestPoint[0], 
                                       p[1]-closestPoint[1], 
                                       p[2]-closestPoint[2]]), 
                            normalize(r[1]))
            
            # doc product > 0 means two vectors angle is from 0~90
            if dp < 0:
                mesh = pm.duplicate(i_mesh, name='Voxel1')
                pm.move(p[0], p[1], p[2], mesh, ws=True)
                self._voxelsList.append(mesh)
                # print "Create Voxel @ "+str(p[0])+","+str(p[1])+","+str(p[2])+" "+str(mesh)
                
        voxelGrp = pm.group(self._voxelsList, name='VoxelGrp1')
        if i_isGroup ==True:
            if len(self._voxelsList)>1:
                pm.polyUnite(voxelGrp, name='V1')
                pm.polyMergeVertex(distance=0.0)
                pm.delete(pm.polyInfo(laminaFaces=True))

        pm.delete(self._oriMdl)
Пример #10
0
import pymel.core as pm


hiddenFaces = []
for j in range(len(pm.selected())):
    for i in pm.selected()[j]:
        if i.getArea() < 1.0e-4:
            hiddenFaces.append(i)
print hiddenFaces
    
result = pm.confirmDialog(title='!!!', button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No', m="hidden faces number: {0} Kill them?".format(len(hiddenFaces)))
#pm.select(hiddenFaces)
#pm.delete(hiddenFaces)

if result == 'Yes':
    for face in hiddenFaces:
        pm.select(face)
        pm.polyListComponentConversion(fromFace = True, toVertex = True)
        pm.polyMergeVertex( distance=0.0 )
else:
    pm.select(hiddenFaces)
Пример #11
0
	def MEL_b019(self):#merge
		stringXYZ = str(self.ui.t001.text())
		floatXYZ = float(stringXYZ)
		pm.polyMergeVertex (distance=floatXYZ, alwaysMergeTwoVertices=True, constructionHistory=True)
Пример #12
0
def mergeDuplicatedVertex(geo, threshold=0.001, only2Vertex=False):
    pm.polyMergeVertex(geo, am=only2Vertex, ch=False, distance=threshold)
Пример #13
0
 def merge(cls):
     pm.polyMergeVertex(ch=False)
Пример #14
0
def merge_verts(mesh, a, b):
    a = mesh.vtx[a]
    b = mesh.vtx[b]
    a.setPosition(b.getPosition(space='world'), space='world')
    pm.polyMergeVertex([a, b], d=0.0000001)