Advertisement
Guest User

bt_hide.py

a guest
Feb 23rd, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. import bpy
  2.  
  3.  
  4. all_collections = []
  5. def get_all_layer_collections():
  6.    
  7.     def get_all_collections_rec(parent):
  8.  
  9.         for child in parent.children:
  10.            
  11.             global all_collections
  12.            
  13.             all_collections.append(child)
  14.             try:
  15.                 get_all_collections_rec(child)
  16.             except:
  17.                 pass
  18.    
  19.     rec_start = bpy.context.view_layer.layer_collection
  20.     get_all_collections_rec(rec_start)
  21.    
  22.     return all_collections
  23.  
  24.  
  25. def hide_view_set_on_visible(unselected):
  26.  
  27.     for lCollection in get_all_layer_collections():
  28.         if lCollection.visible_get() == True:
  29.             for obj in lCollection.collection.objects:
  30.                 if obj.select_get() != unselected:
  31.                     obj.hide_set(True)
  32.  
  33.  
  34. def hide_view_clear_on_visible():
  35.  
  36.     for obj in bpy.data.objects:
  37.         obj.select_set(False)
  38.  
  39.     for lCollection in get_all_layer_collections():
  40.         if lCollection.visible_get() == True:
  41.             for obj in lCollection.collection.objects:
  42.                 if obj.hide_get() == True:
  43.                     obj.hide_set(False)
  44.                     obj.select_set(True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement