Page MenuHome

Python: Bmesh "from_object" broken in 2.8
Closed, ResolvedPublic

Description

Win 10
Gtx 980

Blender 2.8

Creating a bmesh object using from_object used to work in 2.79 but is broken in 2.8

  • Run the following code in the script editor
import bpy, bmesh
bm = bmesh.new()
bm.from_object(bpy.context.active_object,bpy.context.scene)
  • It returns the error:
SystemError: <method 'from_object' of 'BMesh' objects> returned NULL without setting an error

Event Timeline

This looks similar to error I got in https://developer.blender.org/T58734. Except there it was bvhtree.fromObject that was broken.

Philipp Oeser (lichtwerk) claimed this task.
Philipp Oeser (lichtwerk) triaged this task as Confirmed, Medium priority.

Confirmed. Will have a look tomorrow.

As a (temporary) workaround you can use

import bmesh
bm = bmesh.new()
mesh = bpy.context.active_object.to_mesh(bpy.context.depsgraph, True)
bm.from_mesh(mesh)

Thank you, will try it!
I'm a little concerned by performances though, "to_mesh" creates a new mesh data block, so I thought it may be slower than the bmesh method. But maybe i'm wrong.