Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- all_collections = []
- def get_visible_layer_collections():
- def get_all_collections_rec(parent):
- for child in parent.children:
- global all_collections
- if child.visible_get() == True:
- if child.name not in all_collections:
- all_collections.append(child.name)
- try:
- get_all_collections_rec(child)
- except:
- pass
- rec_start = bpy.context.view_layer.layer_collection
- get_all_collections_rec(rec_start)
- return all_collections
- def hide_view_set_on_visible(unselected):
- for vis_collection in get_visible_layer_collections():
- for obj in bpy.data.collections[vis_collection].objects:
- if obj.select_get() != unselected:
- obj.hide_set(True)
- for obj in bpy.context.view_layer.layer_collection.collection.objects:
- if obj.select_get() != unselected:
- obj.hide_set(True)
- global all_collections
- all_collections = []
- def hide_view_clear_on_visible():
- for obj in bpy.data.objects:
- obj.select_set(False)
- for vis_collection in get_visible_layer_collections():
- for obj in bpy.data.collections[vis_collection].objects:
- if obj.hide_get() == True:
- obj.hide_set(False)
- obj.select_set(True)
- for obj in bpy.context.view_layer.layer_collection.collection.objects:
- if obj.hide_get() == True:
- obj.hide_set(False)
- obj.select_set(True)
- global all_collections
- all_collections = []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement