I just imported an .dae file into Blender and I realised that all the faces are triangulated and the faces are separated.
I can fix this manually entering into edit mode, removing doubles and converting triangles to quads. The only problem is that I have something like a few hundred separate objects, so obviously, to repeat all this operations for every single object will be a very time consuming job.
Is here around a script or something to do all this steps automatically? Enter into Edit mode, Remove Doubles, Tris to Quads, leave Edit mode.
You can write a script for this pretty easily… here’s the code that does it:
import bpy
C = bpy.context
scene = C.scene
for ob in C.selected_objects:
if ob.type == 'MESH':
scene.objects.active = ob #set active object
for vert in ob.data.vertices:
vert.select = True #ensure all vertices are selected
bpy.ops.object.mode_set(mode='EDIT') #switch to edit mode
bpy.ops.mesh.remove_doubles() #remove doubles
bpy.ops.mesh.tris_convert_to_quads() #tris to quads
bpy.ops.object.mode_set(mode='OBJECT') #switch to object mode
I found that on the mesh I tested this for, I had to be in vertex or edge selection before I ran the script for the tris_convert_to_quads() function to work, at least in Blender 2.75a. Run the script as is, check the face count for the object, then uncomment the #bpy.ops.mesh.select_mode(type=“VERT”) line and try again.
import bpy
C = bpy.context
scene = C.scene
for ob in C.selected_objects:
if ob.type == 'MESH':
scene.objects.active = ob #set active object
for vert in ob.data.vertices:
vert.select = True #ensure all vertices are selected
bpy.ops.object.mode_set(mode='EDIT') #switch to edit mode
#bpy.ops.mesh.select_mode(type="VERT")
bpy.ops.mesh.remove_doubles() #remove doubles
bpy.ops.mesh.tris_convert_to_quads() #tris to quads
bpy.ops.object.mod
Revised the code to use mesh.select_all() in edit mode to make it fail-safe (original script could fail if first object is in edit mode), which might also be slightly faster on heavy meshes, and moved mesh selection mode change outside the loop, since it is a global property and not per-object (and use RNA prop instead of operator).
import bpy
C = bpy.context
scene = C.scene
C.tool_settings.mesh_select_mode = (True, False, False)
for ob in C.selected_objects:
if ob.type == 'MESH':
scene.objects.active = ob #set active object
bpy.ops.object.mode_set(mode='EDIT') #switch to edit mode
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.remove_doubles() #remove doubles
bpy.ops.mesh.tris_convert_to_quads() #tris to quads
bpy.ops.object.mode_set(mode='OBJECT') #switch to object mode