Converting metaball object to mesh in python returns empty mesh

In my script I’m trying to:

  • Create a metaball object (works)
  • Add metaball elements to it (works)
  • Convert it to a mesh (returns empty mesh)
  • Store the data in a bmesh (works, but is of course still empty)
  • Delete the metaball object (works)

I’d like to understand, why my mesh is always empty and to fix the underlying issue.

My source code:

# Create metaball object
mball ="TempMBall")
mball_obj ="TempMBallObj", mball)

# Add one element to it
ele = = (0.0,0.0,0.0)
ele.use_negative = False
ele.radius = td.sk_base_radius / td.sk_min_radius

print([ele for ele in mball.elements])  # Make sure there is data in mball (there is)

# Convert it to a mesh
mball_mesh = mball_obj.to_mesh()
print([v for v in mball_mesh.vertices]) # Empty!

# Store copy of the mesh in a bmesh for further manipulation
bm =
bm.from_mesh(mball_mesh)    # Still empty!

# Delete metaball object

# My custom mesh manipulation and writing the bmesh into a different object

You need to get the mesh from the evaluated object.

Check the example for details.
The same process applies to any geometry that results from modifiers.

1 Like