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:
authorlijenstina <lijenstina@gmail.com>2017-12-06 07:19:39 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-01-06 18:42:24 +0300
commite12f817f63bea7b17fe2a09e9bd930434e5d7e43 (patch)
treeb2fd6e27629f131eafbcdf2b7245d710c089cd3f
parentdd9965f37c3b68050fc9e50d0e9ef80adae86e80 (diff)
Fix T53406: Avoid toggling visibility on Collision modifier
Bumped version to 0.2.5 Since the Collision modifier visibility was not exposed in the UI trying to avoid unreliable results related to physics and possibly broken setups, for now skip it in the add-on Add reports about skipping: - Skipped modifier name is appended - If there are only skipped modifiers, add a new message about it Correct bl_name of some operators so they are easier to search
-rw-r--r--space_view3d_modifier_tools.py66
1 files changed, 52 insertions, 14 deletions
diff --git a/space_view3d_modifier_tools.py b/space_view3d_modifier_tools.py
index 71a97a58..9076f1a8 100644
--- a/space_view3d_modifier_tools.py
+++ b/space_view3d_modifier_tools.py
@@ -20,7 +20,7 @@
bl_info = {
"name": "Modifier Tools",
"author": "Meta Androcto, saidenka",
- "version": (0, 2, 4),
+ "version": (0, 2, 5),
"blender": (2, 77, 0),
"location": "Properties > Modifiers",
"description": "Modifiers Specials Show/Hide/Apply Selected",
@@ -36,7 +36,7 @@ from bpy.types import Operator
class ApplyAllModifiers(Operator):
bl_idname = "object.apply_all_modifiers"
- bl_label = "Apply All"
+ bl_label = "Apply All Modifiers"
bl_description = ("Apply All modifiers of the selected object(s) \n"
"Active object has to have modifiers for the option to show up")
bl_options = {'REGISTER', 'UNDO'}
@@ -94,7 +94,7 @@ class ApplyAllModifiers(Operator):
class DeleteAllModifiers(Operator):
bl_idname = "object.delete_all_modifiers"
- bl_label = "Remove All"
+ bl_label = "Remove All Modifiers"
bl_description = "Remove All modifiers of the selected object(s)"
bl_options = {'REGISTER', 'UNDO'}
@@ -127,8 +127,8 @@ class DeleteAllModifiers(Operator):
class ToggleApplyModifiersView(Operator):
bl_idname = "object.toggle_apply_modifiers_view"
- bl_label = "Hide Viewport"
- bl_description = "Shows/Hide modifiers of the active / selected object(s) in 3d View"
+ bl_label = "Toggle Visibility of Modifiers"
+ bl_description = "Shows/Hide modifiers of the active / selected object(s) in the 3D View"
bl_options = {'REGISTER'}
@classmethod
@@ -139,31 +139,69 @@ class ToggleApplyModifiersView(Operator):
is_apply = True
message_a = ""
- for mod in context.active_object.modifiers:
- if mod.show_viewport:
- is_apply = False
- break
+ # avoid toggling not exposed modifiers (currently only Collision, see T53406)
+ skip_type = ["COLLISION"] # types of modifiers to skip
+ skipped = set() # collect names
+ count_modifiers = 0 # check for message_a (all skipped)
+
+ # check if the active object has only one non exposed modifier as the logic will fail
+ if len(context.active_object.modifiers) == 1 and \
+ context.active_object.modifiers[0].type in skip_type:
+
+ for obj in context.selected_objects:
+ for mod in obj.modifiers:
+ if mod.type in skip_type:
+ skipped.add(mod.name)
+ continue
+
+ if mod.show_viewport:
+ is_apply = False
+ break
+ else:
+ for mod in context.active_object.modifiers:
+ if mod.type in skip_type:
+ skipped.add(mod.name)
+ continue
+
+ if mod.show_viewport:
+ is_apply = False
+ break
+ count_modifiers = len(context.active_object.modifiers)
# active object - no selection
for mod in context.active_object.modifiers:
+ if mod.type in skip_type:
+ count_modifiers -= 1
+ skipped.add(mod.name)
+ continue
+
mod.show_viewport = is_apply
for obj in context.selected_objects:
+ count_modifiers += len(obj.modifiers)
+
for mod in obj.modifiers:
+ if mod.type in skip_type:
+ skipped.add(mod.name)
+ count_modifiers -= 1
+ continue
+
mod.show_viewport = is_apply
- if is_apply:
- message_a = "Displaying modifiers in the 3D View"
- else:
- message_a = "Hiding modifiers in the 3D View"
+ message_a = "{} modifiers in the 3D View".format("Displaying" if is_apply else "Hidding")
+
+ if skipped:
+ message_a = "{}, {}".format(message_a, "skipping: " + ", ".join(skipped)) if \
+ count_modifiers > 0 else "No change of Modifiers' Visibility, all skipped"
self.report({"INFO"}, message_a)
+
return {'FINISHED'}
class ToggleAllShowExpanded(Operator):
bl_idname = "wm.toggle_all_show_expanded"
- bl_label = "Expand/Collapse All"
+ bl_label = "Expand/Collapse All Modifiers"
bl_description = "Expand/Collapse Modifier Stack"
bl_options = {'REGISTER'}