2.5 remove double ?

like in blender what 's the command in pyton
to let say select a specific object then remove double and if possible show how many double have been removed like when we do it in viewport ?

hopefully this would take less lines of code then to do it manually when building the mesh!

Thanks

http://www.blender.org/documentation/250PythonDoc/search.html?q=remove_double&check_keywords=yes&area=default

this is inside a class

and tried it with this

ob_new = bpy.data.objects.new(name, mesh)
ob_new.data = mesh
bpy.context.scene.objects.link(ob_new)

######################

bpy.ops.object.select_name(name=name, extend=True)

bpy.ops.object.editmode_toggle()
bpy.ops.object.select_all(action=‘TOGGLE’)
bpy.ops.mesh.remove_doubles(limit=0.01)

but on edit toggle line it gives error that context is incorrect ?
if it’s ther right line !

how can you specify the context inside this class ?

also i tough that when an object was created that it was automatically selected
but does not look like it is !

Thanks

ok found it this seems to work now

print (‘scene =’,bpy.context.scene )

bpy.ops.object.select_name(name=name, extend=True)

bpy.context.scene.objects.active = bpy.context.scene.objects[name]

print ( ’ obj_act = context.active_object =’, context.active_object )

bpy.ops.object.editmode_toggle()
bpy.ops.mesh.remove_doubles(limit=0.1)

but how do you know if your in edtit mode or the objet mode
it’s a toggle here ?

Thanks