def _treat_unused_bl_classes():
"""Treat (rewire or unregister) unused Blender bpy.types"""
for bt_name in dir(bpy.types):
# Init
bt_cls = getattr(bpy.types, bt_name, None)
bt_bl_space_type = getattr(bt_cls, "bl_space_type", None)
# Surely used bts
if bt_bl_space_type in _used_bl_space_type: continue
# Other Headers and Panels
# Panels
if issubclass(bt_cls, Panel):
if bt_name in _used_panels: continue
if bt_name not in _unused_panels and bt_bl_space_type in _used_panel_by_bl_space_type:
bt_bl_category = getattr(bt_cls, "bl_category", None)
if bt_bl_category and bt_bl_category in _used_panel_by_bl_category: continue
bt_bl_region_type = getattr(bt_cls, "bl_region_type", None)
if bt_bl_region_type and bt_bl_region_type in _used_panel_by_bl_region_type: continue
# If nothing else applies, unregister the Panel
if DEBUG: print("BFDS: Unregister Panel:", bt_name)
bpy.utils.unregister_class(bt_cls)
continue
# Headers
if issubclass(bt_cls, Header):
if bt_name in _used_headers: continue
if DEBUG: print("BFDS: Rewire Header:", bt_name)
bt_cls.draw = _unused_header_draw # Unused header, rewire its draw function
continue
评论列表
文章目录