Remove Doubles on multiple objects I'm trying to run the remove_doubles edit command on multiple selected objects. This is kinda what I got so far...

import bpy


class remDoubles(bpy.types.Operator):
    """Remove Doubles on multiple objects"""
    bl_label = "Remove Multiple Doubles"
    bl_idname = "object.remove_doubles_multi"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(cls, context):
        return len(context.selected_objects) &gt; 0

    def execute(self, context):

        scene = bpy.context.scene
        sel = context.selected_objects

        for obj in sel:
            scene.objects.active = obj

            #do something here
            print(obj.name)
            bpy.ops.mesh.remove_doubles()

        return {"FINISHED"}

myobject = remDoubles()

myobject.execute()


My knowledge about classes isn't too great, please help.

My code needs some work, it just errors out giving a  'TypeError: bpy_struct.new(type): expected a single argument'

But what i intend doing is run through each object applying the remove doubles command for each.
Firstly operators don't work in a usual create class instance way... the code below

myobject = remDoubles()
myobject.execute()


Will NOT work.

Have a look at the Hello World Example  The HelloWorldOperatoroperator class is defined, registered (known to bpy.ops), then called using bpy.ops. "plus" the bl_idname.  

In your example you would 

bpy.utils.register_class(RemoveDoublesMulti) # changed to camel-case name

# test call to the newly defined operator
bpy.ops.object.remove_doubles_multi()


Using a bmesh approach avoids toggling in and out of edit mode, changing the context object ...  etc.  An alternative for execute:

import bpy
import bmesh

context = bpy.context

distance = 0.0 # remove doubles tolerance.
if True: #def execute(self, context):

    meshes = set(o.data for o in context.selected_objects
                      if o.type == 'MESH')

    bm = bmesh.new()

    for m in meshes:
        bm.from_mesh(m)
        bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=distance)
        bm.to_mesh(m)
        m.update()
        bm.clear()

    bm.free()