Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormeta-androcto <meta.androcto1@gmail.com>2017-06-11 04:15:15 +0300
committermeta-androcto <meta.androcto1@gmail.com>2017-06-11 04:15:15 +0300
commit1c3a84f24f31273587d198cc888f11985b1518b3 (patch)
treef1c0e46a65139f77ea8673b478ff90d39c5d4f6b
parent46a690e72faf7a6c2daeb2aefb6e8f03c79e357b (diff)
display tools: add show/hide by type
-rw-r--r--space_view3d_display_tools/__init__.py15
-rw-r--r--space_view3d_display_tools/select_tools.py102
2 files changed, 116 insertions, 1 deletions
diff --git a/space_view3d_display_tools/__init__.py b/space_view3d_display_tools/__init__.py
index 950f9f09..d76ca8e2 100644
--- a/space_view3d_display_tools/__init__.py
+++ b/space_view3d_display_tools/__init__.py
@@ -402,6 +402,8 @@ class DisplayToolsPanel(Panel):
if obj:
if obj.mode == 'OBJECT':
layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
+ layout.operator_menu_enum("object.hide_by_type", "type", text="Hide By Type")
+ layout.operator_menu_enum("object.show_by_type", "type", text="Show By Type")
col = layout.column(align=True)
col.operator("opr.select_all", icon="MOD_MESHDEFORM")
col.operator("opr.inverse_selection", icon="MOD_REMESH")
@@ -608,10 +610,20 @@ class DisplayToolsPreferences(AddonPreferences):
col.prop(self, "category", text="")
+def DRAW_hide_by_type_MENU(self, context):
+ self.layout.operator_menu_enum(
+ "object.hide_by_type",
+ "type", text="Hide By Type"
+ )
+ self.layout.operator_menu_enum(
+ "object.show_by_type",
+ "type", text="Show By Type"
+ )
+
# register the classes and props
def register():
bpy.utils.register_module(__name__)
-
+ bpy.types.VIEW3D_MT_object_showhide.append(DRAW_hide_by_type_MENU)
# Register Scene Properties
bpy.types.Scene.display_tools = PointerProperty(
type=display_tools_scene_props
@@ -623,6 +635,7 @@ def register():
def unregister():
del bpy.types.Scene.display_tools
selection_restrictor.unregister()
+ bpy.types.VIEW3D_MT_object_showhide.remove(DRAW_hide_by_type_MENU)
bpy.utils.unregister_module(__name__)
diff --git a/space_view3d_display_tools/select_tools.py b/space_view3d_display_tools/select_tools.py
index ca429384..5327ba7f 100644
--- a/space_view3d_display_tools/select_tools.py
+++ b/space_view3d_display_tools/select_tools.py
@@ -210,6 +210,108 @@ class HideRenderAllSelected(Operator):
return {'FINISHED'}
+class OBJECT_OT_HideShowByTypeTemplate():
+
+ bl_options = {'UNDO','REGISTER'}
+
+ type = bpy.props.EnumProperty(items=(
+ ('MESH', 'Mesh', ''),
+ ('CURVE', 'Curve', ''),
+ ('SURFACE', 'Surface', ''),
+ ('META', 'Meta', ''),
+ ('FONT', 'Font', ''),
+ ('ARMATURE', 'Armature', ''),
+ ('LATTICE', 'Lattice', ''),
+ ('EMPTY', 'Empty', ''),
+ ('CAMERA', 'Camera', ''),
+ ('LAMP', 'Lamp', ''),
+ ('ALL', 'All', '')),
+ name='Type',
+ description='Type',
+ default='LAMP',
+ options={'ANIMATABLE'})
+
+ def execute(self, context):
+
+ scene = bpy.context.scene
+ objects = []
+ eligible_objects = []
+
+ # Only Selected?
+ if self.hide_selected:
+ objects = bpy.context.selected_objects
+ else:
+ objects = scene.objects
+
+ # Only Specific Types? + Filter layers
+ for obj in objects:
+ for i in range(0,20):
+ if obj.layers[i] & scene.layers[i]:
+ if self.type == 'ALL' or obj.type == self.type:
+ if obj not in eligible_objects:
+ eligible_objects.append(obj)
+ objects = eligible_objects
+ eligible_objects = []
+
+
+ # Only Render Restricted?
+ if self.hide_render_restricted:
+ for obj in objects:
+ if obj.hide_render == self.hide_or_show:
+ eligible_objects.append(obj)
+ objects = eligible_objects
+ eligible_objects = []
+
+ # Perform Hiding / Showing
+ for obj in objects:
+ obj.hide = self.hide_or_show
+
+ return {'FINISHED'}
+
+ def invoke(self, context, event):
+ return self.execute(context)
+
+
+## show hide by type ## by Felix Schlitter
+class OBJECT_OT_HideByType(OBJECT_OT_HideShowByTypeTemplate, Operator):
+ bl_idname = 'object.hide_by_type'
+ bl_label = 'Hide By Type'
+ hide_or_show = bpy.props.BoolProperty(
+ name="Hide",
+ description="Inverse effect",
+ options={'HIDDEN'},
+ default=1
+ )
+ hide_selected = bpy.props.BoolProperty(
+ name="Selected",
+ description="Hide only selected objects",
+ default=0
+ )
+ hide_render_restricted = bpy.props.BoolProperty(
+ name="Only Render-Restricted",
+ description="Hide only render restricted objects",
+ default=0
+ )
+
+class OBJECT_OT_ShowByType(OBJECT_OT_HideShowByTypeTemplate, Operator):
+ bl_idname = 'object.show_by_type'
+ bl_label = 'Show By Type'
+ hide_or_show = bpy.props.BoolProperty(
+ name="Hide",
+ description="Inverse effect",
+ options={'HIDDEN'},
+ default=0
+ )
+ hide_selected = bpy.props.BoolProperty(
+ name="Selected",
+ options={'HIDDEN'},
+ default=0
+ )
+ hide_render_restricted = bpy.props.BoolProperty(
+ name="Only Renderable",
+ description="Show only non render restricted objects",
+ default=0
+ )
# Register
def register():