Reputation: 4346
I'm working on a script to generate building from plane. While having normal plane is rectangle it's quite easy - you're looking for vertices most -/+X, -/+Y, -/+Z, but what if plane is not of regular shape? Is there a nice easy solution within python api in Blender? In fact is there any clever way to detect faces/edges/vertices on border?
Upvotes: 0
Views: 1036
Reputation: 2794
Look for border edges: these will be ones that are only attached to one face. Look at the Mesh class, specifically the edges, faces and vertices attributes. Unfortunately the edges don’t contain a list of what faces they belong to, so you will have to construct such a mapping, e.g.
EdgeFaces = {} # mapping from edge to adjacent faces
for ThisFace in TheMesh.faces :
for ThisEdge in ThisFace.edge_keys :
if not ThisEdge in EdgeFaces :
EdgeFaces[ThisEdge] = []
#end if
EdgeFaces[ThisEdge].append(ThisFace.edge_keys)
#end for
#end for
Then you just look through EdgeFaces for all keys that map to single-element lists.
Upvotes: 1