UI: Add "Link to Scene" operator in Outliner context menu for objects

Linking an Object to another Scene was only possible
from "3D Viewport → Object → Link/Transfer Data" menu.

This PR adds the operator in objects context menu in Outliner as well.

Additionally, an incorrect error message of the operator is also
updated.

Pull Request: https://projects.blender.org/blender/blender/pulls/159007
This commit is contained in:
1P2D 2026-05-29 11:48:53 +02:00 • committed by Nika Kutsniashvili
parent 36a6fd4608
commit 21db30bfb2
3 changed files with 11 additions and 2 deletions

View file

@ -337,6 +337,15 @@ class OUTLINER_MT_object(Menu):
layout.separator()
operator_context_default = layout.operator_context
if len(bpy.data.scenes) > 10:
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("object.make_links_scene", text="Link Objects to Scene...")
else:
layout.operator_context = 'EXEC_REGION_WIN'
layout.operator_menu_enum("object.make_links_scene", "scene", text="Link Objects to Scene")
layout.operator_context = operator_context_default
if not (space.display_mode == 'VIEW_LAYER' and not space.use_filter_collection):
layout.operator("outliner.id_operation", text="Unlink").type = 'UNLINK'
layout.separator()

View file

@ -3480,7 +3480,7 @@ class VIEW3D_MT_make_links(Menu):
if len(bpy.data.scenes) > 10:
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("object.make_links_scene", text="Link Objects to Scene...", icon='OUTLINER_OB_EMPTY')
layout.operator("object.make_links_scene", text="Link Objects to Scene...")
else:
layout.operator_context = 'EXEC_REGION_WIN'
layout.operator_menu_enum("object.make_links_scene", "scene", text="Link Objects to Scene")

View file

@ -1443,7 +1443,7 @@ static wmOperatorStatus make_links_scene_exec(bContext *C, wmOperator *op)
}
if (scene_to == CTX_data_scene(C)) {
BKE_report(op->reports, RPT_ERROR, "Cannot link objects into the same scene");
BKE_report(op->reports, RPT_ERROR, "Object is already linked to this scene");
return OPERATOR_CANCELLED;
}