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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-08-14 21:56:33 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-08-14 21:56:33 +0400
commite83ef85576a04c41b719176f7797596fe9866a2c (patch)
tree460f2db930a31524e1678b423f7937e740caa0d9 /release/scripts/startup/bl_operators/node.py
parent3220ef9d952b71c397849ea64abb882ea65b4d48 (diff)
Python node operator for combined node collapsing and hiding unused sockets. Socket hide flag is added to RNA as well, but can only be set when the socket is not connected, to avoid dangling links in editor drawing. Currently this operator has no default hotkey, but can be called from the Node menu.
Diffstat (limited to 'release/scripts/startup/bl_operators/node.py')
-rw-r--r--release/scripts/startup/bl_operators/node.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index 2f7fc359864..ddbd46df04f 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -134,3 +134,34 @@ class NODE_OT_add_search(Operator):
context.window_manager.invoke_search_popup(self)
return {'CANCELLED'}
+
+
+class NODE_OT_collapse_hide_unused_toggle(Operator):
+ '''Toggle collapsed nodes and hide unused sockets'''
+ bl_idname = "node.collapse_hide_unused_toggle"
+ bl_label = "Collapse and Hide Unused Sockets"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ # needs active node editor and a tree
+ return space.type == 'NODE_EDITOR' and space.edit_tree
+
+ def execute(self, context):
+ space = context.space_data
+ tree = space.edit_tree
+
+ for node in tree.nodes:
+ if node.select:
+ hide = not node.hide
+
+ node.hide = hide
+ # Note: connected sockets are ignored internally
+ for socket in node.inputs:
+ socket.hide = hide
+ for socket in node.outputs:
+ socket.hide = hide
+
+ return {'FINISHED'}
+