Blender 2.6: “remove doubles” for all objects

One of those “Google-holes”: you’re searching for something – and find nothing. So let’s fix this (and for me, it’s where I can find it again, kind of a web-clipboard).

Here’s the problem: Working with Blender, I imported a 3D scene from another program. After a few clicks, I realize that all vertices are duplicated (Collada import, and no way to change the export settings). Select, toggle edit mode, “remove doubles”, “recalculate normals” would be a valid approach for 10 meshes. But suppose you end up with several 100s? Right, there’s Blender’s built-in Python interpreter. So fire it up an any Blender window you like using the little button on the bottom left:

…and paste the following into that window (you might have to add one press of the return key). The script only works on the selected meshes (and ignores non-meshes), which makes it easier for really huge scenes – you might want to select only a few of them to get started, because Blender will be inresponsive during the script doing its job:

import bpy
if bpy.context.selected_objects != []:
	for ob in bpy.context.selected_objects:
		if ob.type == 'MESH':
			bpy.context.scene.objects.active = ob 
			bpy.ops.object.mode_set(mode='EDIT') 
			bpy.ops.mesh.select_all() 
			# remove doubles:
			bpy.ops.mesh.remove_doubles() 
			# recalculate outside normals:
			bpy.ops.mesh.normals_make_consistent(inside=False)
			bpy.ops.object.mode_set(mode='OBJECT')
Post Tagged with

5 Responses so far.

  1. Sebastian says:

    Thanks a lot man, I tried it on like 40 meshes and worked like a charm. You really made google a better place!

  2. google says:

    magnificent submit, very informative. I’m wondering why the opposite experts of this sector do not realize this. You should continue your writing. I am sure, you have a great readers’ base already!

  3. Abis says:

    Wow thank you sooooooo much. Very valuable script when being used with the cell fracture add-on. You should submit this script to the blender dev’s as an option in the cell fracture menu. Thanks again, you are a wonderful person.

  4. Peter says:

    Whow! Thanks a lot!!!
    Same Problem here with funktion “Tris to Quads” 🙂
    This script will help…

  5. Nath says:

    Nice!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.