How do I make multiple objects Make Local at once?

I want to make all the child objects of an object Make Local at once.
And I select the child objects and invoke the bpy.ops.outliner.id_operation(type='LOCAL') operator.

import bpy

class MakeLocalOperator(bpy.types.Operator):
    bl_idname = 'outliner.make_object_id_data_local'
    bl_label = 'Make Object ID Data Local'
    bl_options = {'REGISTER', 'UNDO'}

    def poll(cls, context):
        return (
            context.area.type == 'OUTLINER'
            and context.object.type == 'EMPTY'

    def execute(self, context):
        object_visibilities = dict()

        def force_show_object(obj):
            object_visibilities[] = {
                'hide': obj.hide_get(),
                'hide_select': obj.hide_select,
                'hide_viewport': obj.hide_viewport,
            obj.hide_select = False
            obj.hide_viewport = False

        def reset_object_visibilities():
            for object_name, visibility in object_visibilities.items():
                obj =[object_name]
                obj.hide_viewport = visibility['hide_viewport']
                obj.hide_select = visibility['hide_select']


        joint_group_object = context.active_object

        for obj in joint_group_object.children:
            if not obj.override_library:

            print(f'id_operation: {}')


        # reset_object_visibilities()

        return {'FINISHED'}

def menu_outliner_object(self, context):

def register():

def unregister():

Selecting the objects succeed, but Make Local failed.
If I manually Make Local from the outliner, it succeeds.

How can I do Select and Make Local within one operator?

what blender is doing when you use the menus is looping through all selected objects and making each one local, so you have to do the same.

edit: actually, you can probably skip making them selected if you like since you already have criteria for which you want to make local.

@sirmaxim Thanks for your reply.
bpy.ops.outliner.id_operation(type='LOCAL') will Make Local selected objects in a single call.

I solved the problem with the following code.

-       bpy.ops.outliner.object_operation(type='SELECT')
+       outliner_context = context.copy()
+       bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
-       bpy.ops.outliner.id_operation(type='LOCAL')
+       bpy.ops.outliner.id_operation(outliner_context, type='LOCAL')


I referred to the following URL:

However, the document says:

If you insist – yes it’s possible, but scripts that use this hack will not be considered for inclusion in Blender and any issue with using it will not be considered a bug, there is also no guaranteed compatibility in future releases.

Do you know of any workarounds?

They define what’s that is about. The short, short version is blender’s UI is single thread so everything you do ties up the interface so it doesn’t refresh until after your code finishes. The ‘correct’ workaround is also listed, which is to exec your operator in a modal so it has it’s own thread and timer.

Thanks for your suggestion.
I’ll try the modal.

By the way, Is it possible to achieve Make Local without using bpy.ops.outliner.id_operation(type='LOCAL')?

I figured out how to achieve it using modal.

However, I gave up on the implementation for the following reasons:

  • There is no way to close a node in the outliner
  • Make Local caused performance problems