I've spent awhile using the extrude tool to construct a mesh, but once problem I've noticed is that if I'm creating a shape with some kind of concavity and two parts of the mesh come back together, then there are two faces pointing into each other and each one has its own set of vertices. I've been consistently entering numbers when extruding so I know that the vertices are in exactly the same position, aside from a possible small amount of floating-point error.

I found this question about merging vertices to create a pyramid, but the answers on it are only applicable to creating pyramids and similar shapes, since they are about manually selecting one of the cube faces to collapse. My mesh likely has hundreds of these duplicated vertices and manually checking the entire mesh is not an option, so I either need to use a tool or get a Python script to automate the process. However, the Alt+M functionality in that question looks useful, since it seems to be able to merge arbitrary vertices.

How do I merge my vertices together? Is there some kind of Python script I can use? Is there a way I can iterate through all of the vertices, check if any two are equal in position, select them, perform the Alt+M functionality from Python, and repeat for all vertices? Since merging vertices would change the amount of vertices, the entire script would basically need run itself many times to merge all of the coinciding vertices, or somehow loop until it finds no coinciding vertices.

  • 1
    $\begingroup$ Have you tried selecting all your vertices in edit mode and then Vertex > Merge Vertices > By Distance or ALT + M > By Distance? Because that is precisely how you merge vertices at the same position. In Python that would be bpy.ops.mesh.remove_doubles() (which is the same operator that is called by the menu entry) or the equivalent of for bmesh bmesh.ops.remove_doubles(). $\endgroup$ – Robert Gützkow Sep 13 '19 at 22:28
  • $\begingroup$ Oh, that's awesome! What distance does it check against, and is it configurable? $\endgroup$ – Aaron Franke Sep 13 '19 at 22:37
  • $\begingroup$ I added that as an answer to blender.stackexchange.com/questions/65605/… since it solved my problem. But I am still curious if the distance is configurable. $\endgroup$ – Aaron Franke Sep 13 '19 at 22:48