Fix T62436: New added Torus won't appear in Local View

Add Object.local_view_get/set

Alternate fix which supports removing from local view & checking
if an object is in local view.
Also avoids redundant refresh.

Matches 2.7x Object.layer_local_view capabilities more closely,
without exposing the flag directly.
This commit is contained in:
Campbell Barton
2019-03-13 10:41:12 +11:00
parent 3ea7a5d869
commit af0ab15e1d
4 changed files with 98 additions and 0 deletions

View File

@@ -133,6 +133,11 @@ def object_data_add(context, obdata, operator=None, name=None):
obj_new.select_set(True)
obj_new.matrix_world = add_object_align_init(context, operator)
space_data = context.space_data
if space_data.type == 'VIEW_3D':
if space_data.local_view:
obj_new.local_view_set(space_data, True)
if obj_act and obj_act.mode == 'EDIT' and obj_act.type == obj_new.type:
bpy.ops.mesh.select_all(action='DESELECT')
obj_act.select_set(True)