Difference between revisions of "Snippet:Finding a polygon island"

From The Foundry MODO SDK wiki
Jump to: navigation, search
Line 20: Line 20:
 
m.geometry.polygons.select( list(island), True )
 
m.geometry.polygons.select( list(island), True )
 
</syntaxhighlight>
 
</syntaxhighlight>
|lang=Python
+
|lang=Python Examples,
 
}}
 
}}

Revision as of 09:56, 26 November 2015

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 )