Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import bmesh
- def get_tri_count(obj):
- """Return the exact triangle count of a mesh object."""
- if obj.type != 'MESH':
- return None
- # Create a temporary bmesh to calculate triangulated face count
- mesh = obj.data
- bm = bmesh.new()
- bm.from_mesh(mesh)
- bmesh.ops.triangulate(bm, faces=bm.faces[:])
- tri_count = len(bm.faces)
- bm.free()
- return tri_count
- def delete_duplicate_meshes():
- seen = {}
- to_delete = []
- for obj in bpy.context.scene.objects:
- if obj.type == 'MESH':
- tri_count = get_tri_count(obj)
- if tri_count is None:
- continue
- # If this tri_count already exists, mark duplicates for deletion
- if tri_count in seen:
- print(f"Duplicate found: {obj.name} (tris={tri_count}) -> deleting")
- to_delete.append(obj)
- else:
- seen[tri_count] = obj
- # Delete duplicates
- bpy.ops.object.select_all(action='DESELECT')
- for obj in to_delete:
- obj.select_set(True)
- bpy.ops.object.delete()
- delete_duplicate_meshes()
Advertisement
Add Comment
Please, Sign In to add comment