def visible_only(bpy_data):
    """
    Filter out all the invisible objects
    """

    def visible(obj):
        return any(obj.is_visible(s) for s in bpy_data['scenes'])

    bpy_data['objects'] = [obj for obj in bpy_data['objects'] if visible(obj)]
    return bpy_data