-
Notifications
You must be signed in to change notification settings - Fork 1
/
toggle_subsurf.py
42 lines (29 loc) · 924 Bytes
/
toggle_subsurf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import bpy
bl_info = {
"name": "Subsurf Toggler",
"author": "Stefan Heinemann",
"blender": (2, 77, 0),
"version": (0, 0, 4),
"location": "Key Bindings",
"description": "Provides an operator for keybindings to toggle the "
"subsurf modifiers",
"category": "Object"
}
class ToggleSubsurf(bpy.types.Operator):
bl_idname = 'object.toggle_subsurf'
bl_label = "Subsurf toggler"
def cur_object(self):
return bpy.context.scene.objects.active
def execute(self, context):
obj = self.cur_object()
modifiers = obj.modifiers
for mod in modifiers:
if mod.type == 'SUBSURF':
mod.show_viewport = not mod.show_viewport
return {'FINISHED'}
def register():
bpy.utils.register_module(__name__)
def unregister():
bpy.utils.unregister_module(__name__)
if __name__ == '__main__':
register()