diff options
author | Eugenio Pignataro <info@oscurart.com.ar> | 2019-01-01 23:44:34 +0300 |
---|---|---|
committer | Eugenio Pignataro <info@oscurart.com.ar> | 2019-01-01 23:44:34 +0300 |
commit | 25ae9e134472c5bca62add0a1db3cdfc2d86aaa7 (patch) | |
tree | e1d13e81594e5de54caeb459062b19fc898ca655 /oscurart_tools | |
parent | 943986f868dcaf5c0c614ff6961f9a00c9369fc6 (diff) |
select doubles rewrite
Diffstat (limited to 'oscurart_tools')
-rw-r--r-- | oscurart_tools/mesh/select_doubles.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/oscurart_tools/mesh/select_doubles.py b/oscurart_tools/mesh/select_doubles.py index 15282b0b..b2a7d434 100644 --- a/oscurart_tools/mesh/select_doubles.py +++ b/oscurart_tools/mesh/select_doubles.py @@ -19,6 +19,7 @@ # <pep8 compliant> import bpy + from mathutils import Vector from bpy.types import Operator from bpy.props import ( @@ -35,26 +36,22 @@ D = bpy.data -def SelDoubles(self, context): - bm = bmesh.from_edit_mesh(bpy.context.object.data) - - for v in bm.verts: - v.select = 0 - - dictloc = {} +def SelDoubles(self, context, distance): + obj = bpy.context.object + me = obj.data + bm = bmesh.from_edit_mesh(me) + double = bmesh.ops.find_doubles(bm, verts=bm.verts, dist=distance) - rd = lambda x: (round(x[0], 4), round(x[1], 4), round(x[2], 4)) + bpy.ops.mesh.select_all(action = 'DESELECT') - for vert in bm.verts: - dictloc.setdefault(rd(vert.co), []).append(vert.index) + for vertice in double['targetmap']: + vertice.select = True - for loc, ind in dictloc.items(): - if len(ind) > 1: - for v in ind: - bm.verts[v].select = 1 - - bpy.context.view_layer.objects.active = bpy.context.view_layer.objects.active + # Switch to vertex select + bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT') + # Show the updates in the viewport + bmesh.update_edit_mesh(me, False) class SelectDoubles(Operator): """Selects duplicated vertex without merge them""" @@ -68,8 +65,12 @@ class SelectDoubles(Operator): context.view_layer.objects.active.type == 'MESH' and context.view_layer.objects.active.mode == "EDIT") + distance : bpy.props.FloatProperty( + default=.0001, + name="Distance") + def execute(self, context): - SelDoubles(self, context) + SelDoubles(self, context,self.distance) return {'FINISHED'} |