2
$\begingroup$

I'm trying to build a large BMesh from scratch in python. I know you can add vertices (or faces or edges) to a BMesh one at a time:

  for v in verts:
    face = bme.verts.new(v)

but this is really slow for many vertices/edges/faces. Is there a batch way to add many vertices at once, avoiding the python overhead?

Googling around I found that the old mesh supported foreach_set() and foreach_get() which were supposed to be fast, but I gather those don't work anymore?

$\endgroup$
1
  • 2
    $\begingroup$ The foreach methods are available to the Mesh not a bmesh and still work. Also Mesh.from_pydata(...) is pretty quick. $\endgroup$
    – batFINGER
    Jun 3, 2020 at 19:01

1 Answer 1

0
$\begingroup$

One way to speed this up would be to use a Python list comprehension. It's probably not the exact answer you're looking for, but it may help with optimizing the code.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .