BMesh: add select next/prev operator

This uses selection history to select the next vert/edge/face based on surrounding topology.
Select previous just removes the last selected element.

Uses key-bindings: Ctrl-Shift +/-
This commit is contained in:
Campbell Barton
2016-01-08 02:54:15 +11:00
parent 08185d2af0
commit 5d118f6dd7
3 changed files with 348 additions and 0 deletions

View File

@@ -148,3 +148,53 @@ class MeshMirrorUV(Operator):
double_warn)
return {'FINISHED'}
class MeshSelectNext(Operator):
"""Select the next element (using selection order)"""
bl_idname = "mesh.select_next_item"
bl_label = "Select Next Element"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return (context.mode == 'EDIT_MESH')
def execute(self, context):
import bmesh
from .bmesh import find_adjacent
obj = context.active_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
if find_adjacent.select_next(bm, self.report):
bm.select_flush_mode()
bmesh.update_edit_mesh(me, False)
return {'FINISHED'}
class MeshSelectPrev(Operator):
"""Select the next element (using selection order)"""
bl_idname = "mesh.select_prev_item"
bl_label = "Select Previous Element"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return (context.mode == 'EDIT_MESH')
def execute(self, context):
import bmesh
from .bmesh import find_adjacent
obj = context.active_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
if find_adjacent.select_prev(bm, self.report):
bm.select_flush_mode()
bmesh.update_edit_mesh(me, False)
return {'FINISHED'}