Quantcast
Channel: mel wiki
Viewing all articles
Browse latest Browse all 610

How can I query if a mesh has a hole or not?

$
0
0
Maybe there's an easier way, but this is one solution :)
The only reason I don't like it is because you have to actually select stuff for the polySelectConstraint to work.
This code simply checks to see if a mesh has border edges. Border edges only show up if there's a hole, that would create a border.
import pymel.core as pm

def selectBorderEdges(mesh):
    mesh = pm.PyNode(mesh)
    if len(mesh.e) == 0:
        raise Exception("")
    pm.select(mesh.e)
    pm.polySelectConstraint(mode=2, type=0x8000, where=True)
    pm.polySelectConstraint(mode=0, disable=True)

def getBorderEdges(mesh):
    sel = pm.ls(selection=True)
    selectBorderEdges(mesh)
    borderEdges = pm.ls(selection=True, flatten=True)
    if sel:
        pm.select(sel)
    else:
        pm.select(clear=True)
    return borderEdges

def hasHole(mesh):
    if getBorderEdges(mesh):
        return True
    else:
        return False

Viewing all articles
Browse latest Browse all 610

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>