def delete_vertex( mesh ) :
	# print mesh
	pm.select(None)
	for v in mesh.getShape().vtx :
		d = True
		if( vert_on_rect_edge( v, mesh.getBoundingBox() ) ) :
			d = False
		try :			
			if( len( v.connectedEdges() ) > 2 ) :
				d = False
		except : 
			d = False
		
		if(d) :
			# print v
			pm.delete(v)
	
	pm.polyMergeVertex( mesh, d=0.001, am=1 )	
	
	# faces = [f for f in mesh.f]

	# for i in range(len(faces)) :
	# 	try : f = faces[i]
	# 	except : break

	# 	if( f.isZeroArea() ) :
	# 		# print f
	# 		pm.delete(f)			
	# 		delete_vertex(mesh)
	# 		break

	pm.delete( mesh, ch=True )
	return mesh
Beispiel #2
0
def delete_vertex(mesh):
    # print mesh
    pm.select(None)
    for v in mesh.getShape().vtx:
        d = True
        if (vert_on_rect_edge(v, mesh.getBoundingBox())):
            d = False
        try:
            if (len(v.connectedEdges()) > 2):
                d = False
        except:
            d = False

        if (d):
            # print v
            pm.delete(v)

    pm.polyMergeVertex(mesh, d=0.001, am=1)

    # faces = [f for f in mesh.f]

    # for i in range(len(faces)) :
    # 	try : f = faces[i]
    # 	except : break

    # 	if( f.isZeroArea() ) :
    # 		# print f
    # 		pm.delete(f)
    # 		delete_vertex(mesh)
    # 		break

    pm.delete(mesh, ch=True)
    return mesh
    def mostlySafeCleanup(self, precision, tolerance):
        objs = pm.ls(selection=True)

        for obj in objs:
            pm.select( obj )
            ## Now the individual object is selected we Convert to faces
            pm.mel.eval("""ConvertSelectionToFaces;""")
            ## Now the faces are all selected
            ## Get the face selection
            faces = pm.ls( selection=True, flatten=True )
            self.deleteFacesInSamePlace( faces, precision, tolerance )
            pm.select( obj )
            pm.mel.eval("""ConvertSelectionToVertices;""")
            pm.polyMergeVertex(  alwaysMergeTwoVertices=False, distance = tolerance, worldSpace=True )
            pm.select( obj )
            pm.mel.eval("""ConvertSelectionToEdges;""") 
            pm.polySewEdge( worldSpace = True, texture = True, tolerance = tolerance )
            pm.select( obj )
            pm.mel.eval("""ConformPolygonNormals;""")  #pm.polyNormal( normalMode = 2 )
        ## Restore the original selection
        pm.select(  objs  )  
Beispiel #4
0
                    command=lambda x: self.shellThicken.shellThicken(
                        thickness=self.thicknessFloatField.getValue(),
                        divisions=self.divisionsIntField.getValue(),
                        distanceForMerge=self.mergeFloatField.getValue(),
                        useTz=self.useTzCheckBox.getValue()
                    )
                )
                #"""
    #def printInfo(self):
        #print( self.useTzCheckBox.getValue() )
        

class MmmmShellThicken(object):
    @classmethod    
    def shellThicken( cls, thickness=1.0, divisions=1, distanceForMerge=0.00001, useTz=True ):
        ## Make a shorthand for listing selection
        lss = lambda: pm.ls(selection=True)
        cmdslss = lambda: cmds.ls(selection=True)
        ## Get the original selection
        oSel = cmdslss()
        
        ## Copy it so we have a list that's safe to modify
        ## without loosing the original selection
        facesSelAtStart = oSel[:]
        facesSelAtStart = getSelectionAsFaces(facesSelAtStart)
        shells = getShells( facesSelAtStart )
        
        outputSelection = []
        ## use pm in the next section
        ## because cmds gives a weird api error
        simpleCount = 0
        complexCount = 0
        for shell in shells:
            print( "handling shell..." )
            print( shell )
            doComplex = False
            if len(shell)==1:
                subShell=shell[0]
                if not ':' in subShell:
                    print( "simple shell is:" )
                    print( shell )
                    simpleCount += 1
                    ## can extrude directly
                    if useTz==False:
                        pm.polyExtrudeFacet( shell, ch=1, keepFacesTogether=1, smoothingAngle=180, divisions=divisions, thickness=thickness )
                    else:
                        pm.polyExtrudeFacet( shell, ch=1, keepFacesTogether=1, smoothingAngle=180, divisions=divisions, thickness=0.0, localTranslateZ = thickness )
                    pm.mel.eval('ConvertSelectionToShell;')
                    shellAfterExtrude = lss()
                    outputSelection += shellAfterExtrude
                else:
                    doComplex=True
            else:
                doComplex=True
            
            if doComplex:
                complexCount+=1
                print( "complex shell selected is:" )
                print( shell )
                pm.select( shell )
                pm.polyChipOff( shell, ch=1, keepFacesTogether=1, dup=1, off=0 )
                facesDup = lss()
                print( facesDup )
                if useTz==False:
                    pm.polyExtrudeFacet( facesDup, ch=1, keepFacesTogether=1, smoothingAngle=180, divisions=divisions, thickness=thickness )
                else:
                    pm.polyExtrudeFacet(
                        facesDup, ch=1, keepFacesTogether=1, smoothingAngle=180,