I am having trouble getting Merge by Distance to work in a python script while it works fine manually in the UI.
When I run Mesh > Clean Up > Merge by Distance on a selection of vertices, the vertices are successfully merged.
The same selection of vertices is not merged when I have them selected and run
bpy.ops.mesh.remove_doubles(threshold=0.001, use_unselected=False)
Info: Removed 0 vertice(s)
{'FINISHED'}
Is there another step needed to script remove_doubles
successfully?
My selection script below selects only the inner top layer of vertices that I want to merge but this issue happens if I just select any group of vertices in the UI so I don't think my selection is the issue.
import bpy
ob=bpy.context.active_object
verts=ob.data.vertices
for v in verts:
if v.co[2] > 0:
v.select=False
else:
v.select=True
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(type="VERT")
bpy.ops.mesh.select_more()
bpy.ops.mesh.select_all(action='INVERT')
bpy.ops.mesh.remove_doubles(threshold=0.001, use_unselected=False)