I've only just started studying the Blender Python API. I'm writing a script (see below) to automate something I've done by hand : joining two adjacent cubes and cleaning up the resulting mesh.
After joining and removing doubles, I expect to have 12 vertices instead of 16 in the resulting object. In the Info header, this seems to be the case, but when I print to the windows terminal I still see 16. Also I do see the output from remove_double(), here's a screenshot :
So what's wrong here ? What is the right way to access an object's mesh, and count its vertices ?
import bpy # Create two adjacent cubes and join them bpy.ops.mesh.primitive_cube_add(location=(1,0,0)) ob = bpy.context.object bpy.ops.mesh.primitive_cube_add(location=(3,0,0)) ob.select = True bpy.ops.object.join() # Expect 16 vertices, 24 edges, 12 faces result = bpy.context.object print(str(len(result.data.vertices))) # Go to edit mode, remove double vertices bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.remove_doubles() # Expect 12 vertices, 20 edges, 11 faces result = bpy.context.object print(str(len(result.data.vertices)))