Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. class VIEW3D_PT_object_type_visibility(Panel):
  2.     bl_space_type = 'VIEW_3D'
  3.     bl_region_type = 'HEADER'
  4.     bl_label = "View Object Types"
  5.     bl_ui_units_x = 6
  6.  
  7.     def draw(self, context):
  8.         layout = self.layout
  9.         layout.use_property_split = True
  10.  
  11.         view = context.space_data
  12.  
  13.         col = layout.column()
  14.  
  15.         attr_object_types = (
  16.             # Geometry
  17.             "mesh",
  18.             "curve",
  19.             "surf",
  20.             "meta",
  21.             "font",
  22.             None,
  23.             # Other
  24.             "armature",
  25.             "lattice",
  26.             "empty",
  27.             "grease_pencil",
  28.             "camera",
  29.             "light",
  30.             "light_probe",
  31.             "speaker",
  32.         )
  33.  
  34.         for attr in attr_object_types:
  35.             if attr:
  36.                 attr_v = "show_object_viewport_"+attr
  37.                 attr_s = "show_object_select_"+attr
  38.  
  39.                 myText = attr.title()
  40.  
  41.                 icon_v = 'VISIBLE_IPO_ON' if getattr(view, attr_v) else 'VISIBLE_IPO_OFF'
  42.                 icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON'
  43.  
  44.                 row = col.row(align=True)
  45.                 row.label(text=myText)
  46.                 row.prop(view, attr_v, text="", icon=icon_v, emboss=False)
  47.                 row.prop(view, attr_s, text="", icon=icon_s, emboss=False)
  48.             else:
  49.                 col.separator()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement