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:
authorBartek Skorupa <bartekskorupa@bartekskorupa.com>2013-05-08 16:31:09 +0400
committerBartek Skorupa <bartekskorupa@bartekskorupa.com>2013-05-08 16:31:09 +0400
commit1ce05a4f76f28a02efc4dc9b1da6f85a4d0f5de9 (patch)
tree2eceeada11ea3ba84cb80c8ef40734c2a70c3187 /node_efficiency_tools.py
parent7fed8de14a4d085d5ba8a86f99b785f445a7a188 (diff)
Added two new options:
1. Detach Outputs (Shift Alt D): Detaches Outputs leaving inputs linked. 2. Link to Output Node (O): Links active node to tree output node. Output node is 'Composite' node or 'Material Output', 'Lamo Output' or 'World Output'.
Diffstat (limited to 'node_efficiency_tools.py')
-rw-r--r--node_efficiency_tools.py72
1 files changed, 71 insertions, 1 deletions
diff --git a/node_efficiency_tools.py b/node_efficiency_tools.py
index eef13bb2..c655e092 100644
--- a/node_efficiency_tools.py
+++ b/node_efficiency_tools.py
@@ -19,7 +19,7 @@
bl_info = {
'name': "Nodes Efficiency Tools",
'author': "Bartek Skorupa",
- 'version': (2, 27),
+ 'version': (2, 28),
'blender': (2, 6, 6),
'location': "Node Editor Properties Panel (Ctrl-SPACE)",
'description': "Nodes Efficiency Tools",
@@ -32,6 +32,7 @@ bl_info = {
import bpy
from bpy.types import Operator, Panel, Menu
from bpy.props import FloatProperty, EnumProperty, BoolProperty
+from mathutils import Vector
#################
# rl_outputs:
@@ -1091,6 +1092,67 @@ class SelectParentChildren(Operator, NodeToolBase):
return {'FINISHED'}
+class DetachOutputs(Operator, NodeToolBase):
+ bl_idname = "node.detach_outputs"
+ bl_label = "Smart Detach"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ def execute(self, context):
+ nodes, links = get_nodes_links(context)
+ selected = context.selected_nodes
+ bpy.ops.node.duplicate_move_keep_inputs()
+ new_nodes = context.selected_nodes
+ bpy.ops.node.select_all(action="DESELECT")
+ for node in selected:
+ node.select = True
+ bpy.ops.node.delete_reconnect()
+ for new_node in new_nodes:
+ new_node.location.y += 100.0
+ new_node.select = True
+
+ return {'FINISHED'}
+
+class LinkToOutputNode(Operator, NodeToolBase):
+ bl_idname = "node.link_to_output_node"
+ bl_label = "Link to Output Node"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.active_node
+
+ def execute(self, context):
+ nodes, links = get_nodes_links(context)
+ active = nodes.active
+ output_node = None
+ for node in nodes:
+ if (node.type == 'OUTPUT_MATERIAL' or\
+ node.type == 'OUTPUT_WORLD' or\
+ node.type == 'OUTPUT_LAMP' or\
+ node.type == 'COMPOSITE'):
+ output_node = node
+ break
+ if not output_node:
+ bpy.ops.node.select_all(action="DESELECT")
+ type = context.space_data.tree_type
+ print(type)
+ if type == 'ShaderNodeTree':
+ output_node = nodes.new('ShaderNodeOutputMaterial')
+ elif type == 'CompositorNodeTree':
+ output_node = nodes.new('CompositorNodeComposite')
+ output_node.location = active.location + Vector((300.0, 0.0))
+ nodes.active = output_node
+ if (output_node and active.outputs):
+ output_index = 0
+ for i, output in enumerate(active.outputs):
+ if output.type == output_node.inputs[0].type:
+ output_index = i
+ break
+ links.new(active.outputs[output_index], output_node.inputs[0])
+
+ return {'FINISHED'}
+
+
#############################################################
# P A N E L S
#############################################################
@@ -1113,9 +1175,11 @@ class EfficiencyToolsPanel(Panel, NodeToolBase):
box.menu(NodeAlignMenu.bl_idname, text="Align Nodes (Shift =)")
box.menu(CopyToSelectedMenu.bl_idname, text="Copy to Selected (Shift-C)")
box.operator(NodesClearLabel.bl_idname).option = True
+ box.operator(DetachOutputs.bl_idname)
box.menu(AddReroutesMenu.bl_idname, text="Add Reroutes ( / )")
box.menu(NodesSwapMenu.bl_idname, text="Swap Nodes (Shift-S)")
box.menu(LinkActiveToSelectedMenu.bl_idname, text="Link Active To Selected ( \\ )")
+ box.operator(LinkToOutputNode.bl_idname)
#############################################################
@@ -1136,9 +1200,11 @@ class EfficiencyToolsMenu(Menu, NodeToolBase):
layout.menu(NodeAlignMenu.bl_idname, text="Align Nodes")
layout.menu(CopyToSelectedMenu.bl_idname, text="Copy to Selected")
layout.operator(NodesClearLabel.bl_idname).option = True
+ layout.operator(DetachOutputs.bl_idname)
layout.menu(AddReroutesMenu.bl_idname, text="Add Reroutes")
layout.menu(NodesSwapMenu.bl_idname, text="Swap Nodes")
layout.menu(LinkActiveToSelectedMenu.bl_idname, text="Link Active To Selected")
+ layout.operator(LinkToOutputNode.bl_idname)
class MergeNodesMenu(Menu, NodeToolBase):
@@ -1510,6 +1576,10 @@ kmi_defs = (
(ChangeMixFactor.bl_idname, 'ONE', True, True, True, (('option', 1.0),)),
# CLEAR LABEL (Alt L)
(NodesClearLabel.bl_idname, 'L', False, False, True, (('option', False),)),
+ # DETACH OUTPUTS (Alt Shift D)
+ (DetachOutputs.bl_idname, 'D', False, True, True, None),
+ # LINK TO OUTPUT NODE (O)
+ (LinkToOutputNode.bl_idname, 'O', False, False, False, None),
# SELECT PARENT/CHILDREN
# Select Children
(SelectParentChildren.bl_idname, 'RIGHT_BRACKET', False, False, False, (('option', 'CHILD'),)),