Questions tagged [bmesh]

Blender Python Bmesh module, added in 2.63, provides an alternative method of manipulating meshes "giving Python access to the functions used by Blender’s own mesh editing tools.". Use this tag for question about using the Bmesh module in Python scripts and add-ons.

The bmesh module is discussed in the BMesh Design Document in the Blender wiki. The manual describes the bmesh module thusly:

This API gives access the Blender’s internal mesh editing API, featuring geometry connectivity data and access to editing operations such as split, separate, collapse and dissolve. The features exposed closely follow the C API, giving Python access to the functions used by Blender’s own mesh editing tools.

bmesh manipulation of meshes tends to be faster than using bpy.ops operations on the mesh because there are fewer screen redraws.

Use this tag for questions about using the bmesh module from python.

The usual workflow is to

  • create a new bmesh,
  • copy the mesh data from an object to it,
  • use bmesh module tools to modify the mesh in bmesh format, an
  • replace the original mesh data with the modified bmesh

as shown in this trivial example from the manual:

# This example assumes we have a mesh object selected

import bpy import bmesh

Get the active mesh

me = bpy.context.object.data

Get a BMesh representation

bm = bmesh.new() # create an empty BMesh bm.from_mesh(me) # fill it in from a Mesh

Modify the BMesh, can do anything here...

for v in bm.verts: v.co.x += 1.0

Finish up, write the bmesh back to the mesh

bm.to_mesh(me) bm.free() # free and prevent further access

396 questions
3
votes
0 answers

Updating BMesh element indices

I've noticed that after calling bmesh.utils.edge_split the new elements (vert, edge, loops) have -1 indices. They stay -1 even after calling ensure_lookup_table() for all elements. But, after calling bmesh.utils.edge_split a second time, the…
atb
  • 131
  • 2
2
votes
0 answers

Change edge length using BMesh Operators

I have read some articles about access to the Mesh primitives like edge and vertex, but all those are outdated today for my understanding (such as this). My question is how by utilising python script (and BMesh Operators I guess) to set precise…
Vitalii Sadovshikov
  • 560
  • 1
  • 5
  • 14
2
votes
0 answers

bmesh from_edit_mesh points to old dead bmesh after free

I've been struggling with a bmesh problem for a while now and I can't wrap my head around it. When I free my bmesh data and try to make a new bm instance with the same object, it points to the old freed data. Simplified code snippet: import…
Singulasar
  • 23
  • 6
1
vote
3 answers

Triangularization problem in symmetric objects

If I create a symmetric object without the mirror modifier, the triangularizations of the mesh aren't symmetric during rendering. Is this a feature or bug ?
user1395
1
vote
1 answer

Change proportion on base mesh

I discovered a video that shows a very quick way to make base mesh (skin modifier as everyone already knows) but it's a timelapse, so there's no explanation at all. In 01:00 he starts to scale vertex to change proportion for each part of the…
Carlos
  • 91
  • 1
1
vote
1 answer

Creating bmesh from an object: why is scale ignored?

I notice that when you create a bmesh from an object using bm = bmesh.new() bm.from_mesh(obj.data) the scale of the object is ignored, in the sense that you get the same bmesh regardless of whether you do obj.scale = (100, 100, 100) or not. Is…
Sibbs Gambling
  • 719
  • 2
  • 15
  • 30
0
votes
1 answer

How do I extract the vertices indices from an Geometrical nodes model that belong to a given edge (always a start and end vertice)

I am looking to retrieve al the starting and ending vertices per edge of an object (standard box in this case). For this I have created the following code: import bpy import bmesh import numpy as np # get a reference to the active object mesh_obj =…
Peter_Ko
  • 13
  • 1