I've downloaded some 3d models of a city with a ton of topologic errors. I am trying to fix some iterating through the objects and running dissolve_degenerate
. But when calling the function I get a Runtime error : RuntimeError: Operator bpy.ops.mesh.dissolve_degenerate.poll() failed, context is incorrect. I see this a fairly common problem for Blender neophites like me, but despite looking to several examples of "context incorrect" I can't figure out how fix this problem. Can somebody tell me how to set the right context to call dissolve_degenerate from the python shell?
# deselect all objects
bpy.ops.object.select_all(action='DESELECT')
for i,o in enumerate(bpy.data.objects):
if o.type == 'MESH':
o.select_set(True)
bpy.ops.object.editmode_toggle()
dim_min = min(o.dimensions)
# the following line throws an error
bpy.ops.mesh.dissolve_degenerate(threshold=dim_min/100)
o.select_set(False)
print(o.name)
if i>10:
break