diff --git a/docs/nodes/scene/get_objects_data.rst b/docs/nodes/scene/get_objects_data.rst index 72d7e3b828..d41d3b809b 100644 --- a/docs/nodes/scene/get_objects_data.rst +++ b/docs/nodes/scene/get_objects_data.rst @@ -1,8 +1,8 @@ Get Objects Data ================ -.. image:: https://github.com/nortikin/sverchok/assets/14288520/3794a700-0b9e-4b05-8d54-d3b330ddf112 - :target: https://github.com/nortikin/sverchok/assets/14288520/3794a700-0b9e-4b05-8d54-d3b330ddf112 +.. image:: https://github.com/nortikin/sverchok/assets/14288520/d7662f9f-d398-4b73-8337-d0d228f104bc + :target: https://github.com/nortikin/sverchok/assets/14288520/d7662f9f-d398-4b73-8337-d0d228f104bc Functionality ------------- @@ -23,8 +23,8 @@ limitations: - When you use the ``Post`` mode Sverchok/Blender expect Objects to be visible. If you want to "hide" the original Objects in the scene to avoid visual clutter, you can place them into a Collection and hide the collection. This is a current Blender API limitation. - Another method to work with objects - select wireframe mode and hide objects in Render by buttons: - .. image:: https://github.com/nortikin/sverchok/assets/14288520/0ef92cf2-d512-49f8-b803-da9af748e829 - :target: https://github.com/nortikin/sverchok/assets/14288520/0ef92cf2-d512-49f8-b803-da9af748e829 + .. image:: https://github.com/nortikin/sverchok/assets/14288520/30158800-3cd8-483d-a162-2d13ddfdc289 + :target: https://github.com/nortikin/sverchok/assets/14288520/30158800-3cd8-483d-a162-2d13ddfdc289 .. raw:: html diff --git a/nodes/scene/get_objects_data.py b/nodes/scene/get_objects_data.py index 9240a60428..d42bf4687f 100644 --- a/nodes/scene/get_objects_data.py +++ b/nodes/scene/get_objects_data.py @@ -188,6 +188,56 @@ def update_render_type(self, context): items = hide_render_types, default = 'RESTRICT_RENDER_OFF', update = update_render_type) + + align_3dview_types = [ + ('ISOLATE_CURRENT', "", "Toggle local view with only current selected object in the list\nPress again to restore view", "PIVOT_CURSOR", 0), + ('ISOLATE_ALL', "", "Toggle local view with all objects in the list\nPress again to restore view", "PIVOT_INDIVIDUAL", 1), + ] + + def update_align_3dview(self, context): + obj_in_list = self.object_names[self.active_obj_index] + if obj_in_list: + # reset all selections + for obj in bpy.context.selected_objects: + obj.select_set(False) + + # select all objects in list of this node + if self.align_3dview_type=='ISOLATE_ALL': + for obj in self.object_names: + if obj.name in bpy.data.objects: + bpy.data.objects[obj.name].select_set(True) + + if obj_in_list.name in bpy.data.objects: + obj_in_scene = bpy.data.objects[obj_in_list.name] + obj_in_scene.select_set(True) + bpy.context.view_layer.objects.active = obj_in_scene + + for area in bpy.context.screen.areas: + if area.type == 'VIEW_3D': + ctx = bpy.context.copy() + ctx['area'] = area + ctx['region'] = area.regions[-1] + # test if current mode is local view: https://blender.stackexchange.com/questions/290669/checking-for-object-being-in-local-view + if self.align_3dview_type_previous_value!=self.align_3dview_type and area.spaces.active.local_view: + bpy.ops.view3d.localview(ctx, frame_selected=False) + self.align_3dview_type_previous_value = self.align_3dview_type + bpy.ops.view3d.localview(ctx, frame_selected=False) + #bpy.ops.view3d.view_selected(ctx) + break + + pass + return + + align_3dview_type : EnumProperty( + name = "Local View", + items = align_3dview_types, + default = 'ISOLATE_CURRENT', + update = update_align_3dview) + + align_3dview_type_previous_value : EnumProperty( + name = "Local View", + items = align_3dview_types, + default = 'ISOLATE_CURRENT') def sv_init(self, context): @@ -267,6 +317,8 @@ def sv_draw_buttons(self, context, layout): col.row().prop(self, 'display_type', expand=True) col = row.column() col.row().prop(self, 'hide_render_type', expand=True) + col = row.column() + col.row().prop(self, 'align_3dview_type', expand=True) col = layout.column(align=True) row = col.row(align=True)