Skip to content

Commit

Permalink
fix #5055. Append quick method to display_type and hide_render of sel…
Browse files Browse the repository at this point in the history
…ected objects in the node "Get Objects Data"

v.002. Update Docs
v.003. Append switch to local view. Update Docs
  • Loading branch information
satabol committed Nov 10, 2023
1 parent 838714a commit 63bd2bd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/nodes/scene/get_objects_data.rst
Original file line number Diff line number Diff line change
@@ -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
-------------
Expand All @@ -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

Expand Down
52 changes: 52 additions & 0 deletions nodes/scene/get_objects_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 63bd2bd

Please sign in to comment.