Index: source/blender/editors/mesh/editmesh_select.c =================================================================== --- source/blender/editors/mesh/editmesh_select.c (revision 53424) +++ source/blender/editors/mesh/editmesh_select.c (working copy) @@ -63,8 +63,10 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "mesh_intern.h" +#include "BKE_deform.h" #include "UI_resources.h" @@ -3225,3 +3227,91 @@ RNA_def_boolean(ot->srna, "select_bigger", 0, "Select Bigger", "Select bigger regions instead of smaller ones"); } + +static int edbm_select_vert_group_count_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = BMEdit_FromObject(obedit); + BMVert *eve; + BMEdge *eed; + BMFace *efa; + BMIter iter; + + bDeformGroup *group = obedit->defbase.first; + + const int compare = RNA_enum_get(op->ptr, "compare"); + + int defcount = 0; //total number of vertex groups on the object + int vertdefcount = 0; //number of vertex groups current vert is assigned to + int targetcount = RNA_int_get(op->ptr, "count"); //target value we are comparing vertices against + int i = 0; //for loop iteration + + while(group)//calculate the number of vertex groups. Is there a variable that stores this information somewhere? + { + group = group->next; + defcount++; + } + + if (!RNA_boolean_get(op->ptr, "extend")) + EDBM_flag_disable_all(em, BM_ELEM_SELECT); + + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + + MDeformVert *dv = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + vertdefcount = 0; + + + for(i=0; ibm, eve, select); + } + } + else if(compare == SIM_CMP_GT){ + if(vertdefcount > targetcount){ + BM_vert_select_set(em->bm, eve, select); + } + } + else if(compare == SIM_CMP_LT){ + if(vertdefcount < targetcount){ + BM_vert_select_set(em->bm, eve, select); + } + } + + } + } + + EDBM_selectmode_flush(em); + + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); + + return OPERATOR_FINISHED; +} + +void MESH_OT_select_vert_group_count(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Verts Group Count"; + ot->description = "Selects vertices by number of vertex groups"; + ot->idname = "MESH_OT_select_vert_group_count"; + + /* api callbacks */ + ot->exec = edbm_select_vert_group_count_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_enum(ot->srna, "compare", prop_similar_compare_types, SIM_CMP_EQ, "Compare", ""); + + RNA_def_int(ot->srna, "count", 0, 0, INT_MAX, + "Group Count", "Number of vertex groups to compare", 0, 100); + RNA_def_boolean(ot->srna, "extend", 0, + "Extend Selection", "Extend selection instead of deselecting everything first"); +} Index: source/blender/editors/mesh/mesh_ops.c =================================================================== --- source/blender/editors/mesh/mesh_ops.c (revision 53424) +++ source/blender/editors/mesh/mesh_ops.c (working copy) @@ -160,6 +160,8 @@ WM_operatortype_append(MESH_OT_wireframe); WM_operatortype_append(MESH_OT_edge_split); + WM_operatortype_append(MESH_OT_select_vert_group_count); + #ifdef WITH_BULLET WM_operatortype_append(MESH_OT_convex_hull); #endif Index: source/blender/editors/mesh/mesh_intern.h =================================================================== --- source/blender/editors/mesh/mesh_intern.h (revision 53424) +++ source/blender/editors/mesh/mesh_intern.h (working copy) @@ -138,6 +138,7 @@ void MESH_OT_solidify(struct wmOperatorType *ot); void MESH_OT_select_nth(struct wmOperatorType *ot); void MESH_OT_select_next_loop(struct wmOperatorType *ot); +void MESH_OT_select_vert_group_count(wmOperatorType *ot); extern struct EnumPropertyItem *corner_type_items;