# Is there a library/addon for scripters that supports geometry related selection operations?

I find myself writing various operations that one would expect to be available in blender (somewhere). These operations largely stem around things like selecting subsets of a geometry, finding various metrics like the centers/centroids of these selections. Really it's a sort of mish mash of grouping and sorting operations that one might expect to be there.

If such functionality does exist I do not mind rolling my own as it were but it does seem that some one must have done this before me and that there ought to be some sort of library available in blender that accomplishes these tasks.

The best I've been able to dig up is mathutils.geometry and bpy_extras.mesh_utils which does a little bit of this. I saw a small note on swizzling (Where the Vector.xyzw=Vector.zwxy methods are used for swapping point co-ordinates about some). There is a bit more of this kind of thing in bmesh.utils and bmesh.geometry but not much.

Is there a library/addon for scripters that supports these geometry related operations ?

## Update:

Hmm.. Ok so for context consider this answer on BlenderOverflow providing some one with the means of selecting and extruding a subset faces. They know about extrude, they know about selection but they can't get both together without this function. In normal blender work flow a human does this job but if you're trying to do anything by scripting the human becomes moot.

def selectPlane(bm, normal = 'z', location = Vector((0,0,0)), feature = 'verts', tolerance = 0.1) : # bpy.context.active_object.location
'''
Select all the geometry within a plane described by a position and a normal
'''
normal = normal if isinstance(normal, Vector) else AXES[normal.upper()]
if isinstance(feature, list) :
return {key : planeSelect(bm, normal, feature, location, tolerance) for key in feature}
else :
return {'verts' : [vert for vert in bm.verts if abs(vert.co.__sub__(location).dot(normal)) < tolerance],
'edges' : [],
'faces' : [face for face in bm.faces if all([abs(vert.co.__sub__(location).dot(normal)) < tolerance for vert in face.verts])]}[feature]


It's not an advanced function by any means it merely selects a set of faces, edges and/or verts lying in a plane and returns a result that satisfies the geom argument in bmesh.ops operations. The main difference here is that instead of the user selecting portions of geometry to edit there is a little algorithm doing the job.

I'm really just trying to find out if this algortihm has some long lost cousins in a library somewhere ? the obvious cousins are primitive selectors, such as points within or on a cude/cylinder/triangle/circle but there might be some stranger cousins who select all faces/edges and/or verts on a flowing/noisy/glossy/elliptic/parabolic surface or space.

To be clear I'm not looking for some one to write such code I'm just wondering if some one has. If no one has I can make what I have available.

• Carel, could you provide a particular example, with sample code, of one of the operations you have in mind? – batFINGER Sep 1 '16 at 15:33
• @batFINGER I updated the question to shed some more light on it. If I must do more let me know.sorry it took so long to reply I had closed the tab and needed to find it again, I was also answering the linked question as it's related/the reason for this one. – Carel Sep 2 '16 at 12:28