Decimate several Objcets using sth. like "edge-Cost"

Hey Guys,

I am looking for a possibility to reduce the polygon count greatly (decimate modifier) for a large number of objects in a scene via python-script. It is very important for me to keep the individual object information (names, materials, parenting etc.). So far I have tried the following:

Version 1:

  • Link modifiers to all objects

Problem: all objects are reduced by the same percentage -value, this destroys all objects with few polygons (reduced to much), and in many case it reduces far to little. This caused by the fact, that every object is reduced by the same value, doesn’t matter how complex or simple they are.
Advantage: extremely fast processing (multi-threading, cpu at 100% utilization)

I’m trying to combine version 1 with something like “polygon density” or “edge-cost” on the basis of common reduce-methods. Unfortunately, the Blender internal “decimate” code is not comprehensible to me, is there possibly a documentation or something similar here?

Does anyone have an idea, how i could solve this in python?

Version 2:

  • Join all objects and decimate together

Problems: loss of the absolutely necessary object information, extremely slow (single thread)
Advantage: very good low-poly quality

Is there possibly a possibility to save the required object information by script and separate and restore the original objects after decimating?

Has anyone possibly a completely different idea how I could implement the whole thing?

Thanks in advance!

I don’t think Blender has a “polygon density” or “edge-cost” feature available. You could write a very very simple version of this in Python by looking at the number of vertices each mesh object has with something like:

import bpy

for obj in bpy.context.scene.objects:
    if obj.type == "MESH":
        vert_count = len(obj.data.vertices)
        if vert_count > 10000:
            print("do high vert decimate here")
        elif vert_count > 100:
            print("do low vert decimate here")

If you wanted edges or polygons, you could replace the “len(obj.data.vertices)” line with one of the two below:

len(obj.data.edges)
len(obj.data.polygons)

For example:

import bpy

for obj in bpy.context.scene.objects:
    if obj.type == "MESH":
        poly_count = len(obj.data.polygons)
        if poly_count > 10000:
            print("do high poly decimate here")
        elif poly_count > 100:
            print("do low poly decimate here")