How to Clear mesh data

Is there any possible way to clear “[obj].vertices” and “polygons” just like “[obj].splines.clear()”.

Create Primitive objects is part of my BsMax add-on. create the Curve object working well but for Mesh objects the trick I used is delete old mesh and create new one with same name but it breaks when object has linked duplicate or is in Edit mode.
And problem with Bmesh is it works on Edit mode and Create of object most be in Object mode.

bmesh does work in object mode too !

o = context.object
mesh =
bm =

# if you need objects mesh with modifiers evaluated     
# depsgraph = context.evaluated_depsgraph_get()
# mesh = o.evaluated_get(depsgraph).to_mesh()

# clear bmesh geometry
1 Like

Thank you, but seems this not works.
If it works, right after bm.clear() the mesh.vertices count must be zero but it still same.
Am I missed doing some thing else?

At least from API doc should work that way (and in facts it does), possibly a value is not cleaned according - or something goes wrong with this part.
If you try to access any vertex after clear(), blender should crash with an access_violation.

1 Like

Apparently it’s coming in 2.81, which will have a mesh.clear_geometry() call. See here, under Mesh Replacement.