[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4514] trunk/py/scripts/addons/ node_efficiency_tools.py: Added two new options:
Bartek Skorupa
bartekskorupa at bartekskorupa.com
Wed May 8 14:31:10 CEST 2013
Revision: 4514
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4514
Author: bartekskorupa
Date: 2013-05-08 12:31:09 +0000 (Wed, 08 May 2013)
Log Message:
-----------
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'.
Modified Paths:
--------------
trunk/py/scripts/addons/node_efficiency_tools.py
Modified: trunk/py/scripts/addons/node_efficiency_tools.py
===================================================================
--- trunk/py/scripts/addons/node_efficiency_tools.py 2013-05-08 04:48:55 UTC (rev 4513)
+++ trunk/py/scripts/addons/node_efficiency_tools.py 2013-05-08 12:31:09 UTC (rev 4514)
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
(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'),)),
More information about the Bf-extensions-cvs
mailing list