Creating and removing mesh vertices using BMesh

The BMesh module provides users of the Blender Python API with far more options for editing meshes than the usual object data structure.

A BMesh object could be created from the currently active mesh as follows:

The source mesh must be in the Edit mode.

To create a new vertex, we can use the new() method of the “verts” collection of the BMesh object. We should pass the coordinates, in which place this point will be created, in the method parameter. Coordinates are considered in the object’s local coordinate system.

For example, let’s create copies of all selected mesh vertices, raising them by 3 units by the Z axis.

Loop through all the selected vertices, get their coordinates, add 3 to the Z-component of the coordinates and create new vertices in the required place.

To remove points in a BMesh, we can use the remove() method of the “verts” collection of the BMesh object.

Now let’s delete the initially selected points from which we made copies.

We should pass a pointer to the vertex to be removed through the parameter of the remove() method.

Now apply all the changes to the original mesh so that they are displayed in the viewport, and clear the BMesh object.

5 1 vote
Article Rating
Notify of

0 Comment
Inline Feedbacks
View all comments