Finding a polygon island

From The Foundry MODO SDK wiki
Jump to: navigation, search

Description:

Find a polygon island starting with a single selected polygon (TD SDK).

Code:

import modo
 
# Get the selected mesh
m = modo.Mesh()
 
# And the selected polyons
queue = list(m.geometry.polygons.selected)
 
island = set()
 
while queue:
	poly = queue.pop()
	if not poly in island:
		island.add(poly)
		queue.extend( poly.neighbours )
 
m.geometry.polygons.select( list(island), True )