I'm new to Blender and I'm having a few issues attempting to run a 'limited dissolve' over thousands of objects. Is there a simple way of doing this?

What I've tried so far is:

  • Select all objects/faces in the "object mode" and then in the edit mode run the limited dissolved feature. However for some reason 'limited dissolved' seems to only work on single faces/object.

  • Python script looping through all objects and selecting the objects individually to do a 'limited dissolve' on each one. However when I run the script the dissolve_limited method doesn't seem to work - see code below:

    bpy.data.objects['Shape_IndexedFaceSet.'+str(HundsCol)+str(TensCol)+str(CountTens)].select = True
    bpy.data.objects['Shape_IndexedFaceSet.'str(HundsCol)+str(TensCol)+str(CountTens)].select = False

To change the context object (for operators) use

context.scene.objects.active = obj

or new in 2.8, instead use

context.view_layer.objects.active = obj
# and select with 

as well as (or instead of) setting the select property.

In your code above you would be running the op on context object for each object.

For multiple objects consider using the bmesh module as shown in this Related Answer, replace the remove doubles bmesh operator with limited dissolve.

Test code, runs the limited dissolve on every selected mesh object.

import bpy
import bmesh
from math import radians

context = bpy.context

distance = 0.0 # remove doubles tolerance.
if True: #def execute(self, context):

    meshes = set(o.data for o in context.selected_objects
                      if o.type == 'MESH')

    bm = bmesh.new()

    for m in meshes:
        bmesh.ops.dissolve_limit(bm, angle_limit=radians(1.7), verts=bm.verts, edges=bm.edges)


On a side note, suggest using string formatting to make key names.

key = "Shape_IndexedFaceSet.%d_%d" % (hundreds, tens)
obj = scene.objects.get(key) # obj is None if not exist.

or with f-strings

key = f"Shape_IndexedFaceSet.{hundreds}_{tens}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.