Using the Mirror modifier greatly simplifies the modeling process on symmetrical objects. To properly optimize a mesh for use with this modifier, we should always delete the part of the mesh that will be mirrored; otherwise, we’ll immediately end up with duplicate geometry, which will lead to problems with further editing and shading. This geometry cleanup process can be optimized with a simple script that automatically removes unnecessary points and adds the modifier to the mesh.
For example, let’s create a script to assign a Mirror modifier along the X axis for the currently active object.
Suppose we’re currently in the edit mode.
Define a BMesh object and transfer all the geometry from the active object to it.
|
1 2 3 |
import bmesh bm = bmesh.from_edit_mesh(bpy.context.object.data) |
If we simply want to select all the vertices to the right of the object’s center (its origin) along the X axis for further manipulation, we can simply loop through the vertices and select those with an X coordinate greater than zero.
We use the “greater than” condition to avoid selecting points on the axis around which the mirroring will be performed.
|
1 2 |
for vertex in bm.verts: vertex.select = True if vertex.co.x > 0.0 else False |
If we want to delete these points, we can get them as a list and use the delete() operator from the bmesh.ops package.
|
1 2 |
selected_verts = [_vertex for _vertex in bm.verts if _vertex.select] bmesh.ops.delete(bm, geom=selected_verts, context='VERTS') |
Now we can return the edited geometry from the BMesh to the original object.
And clear the BMesh object we no longer need.
|
1 2 |
bmesh.update_edit_mesh(bpy.context.object.data) bm.free() |
Half of the mesh’s geometry has now been deleted.
Assign a Mirror modifier to “return” it as a mirrored geometry.
|
1 2 |
mirror = bpy.context.object.modifiers.new(name='Mirror', type='MIRROR') mirror.use_axis[0] = True |
Now the object appears intact again, as the assigned modifier mirrors the remaining geometry around the X-axis.
This way, we quickly assigned the Mirror modifier and adjusted the geometry to match it, eliminating the duplicate geometry.

.blend file on Patreon