import bpy

import random

#def main(context):
#    for ob in context.scene.objects:
#        print(ob)

class ClearSplitnormals(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.clear_splitnormals"
    bl_label = "Clear Splitnormals"

    #@classmethod
    #def poll(cls, context):
    #    return context.active_object is not None

    def execute(self, context):
        for o in bpy.context.selected_objects:
            if not o.type == 'MESH':
                
                # Remember which is not an 'MESH'
                test.append(o)
                continue
            
            bpy.context.view_layer.objects.active = o
            bpy.ops.mesh.customdata_custom_splitnormals_clear()

        #main(context)
        return {'FINISHED'}


def register():
    bpy.utils.register_class(ClearSplitnormals)


def unregister():
    bpy.utils.unregister_class(ClearSplitnormals)


if __name__ == "__main__":
    register()

    # test call
    #bpy.ops.object.random_diffuse_shader()





