Skip to content
Snippets Groups Projects
Commit 1ce05a4f authored by Bartek Skorupa's avatar Bartek Skorupa
Browse files

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'.
parent 7fed8de1
Branches
Tags
No related merge requests found
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
bl_info = { bl_info = {
'name': "Nodes Efficiency Tools", 'name': "Nodes Efficiency Tools",
'author': "Bartek Skorupa", 'author': "Bartek Skorupa",
'version': (2, 27), 'version': (2, 28),
'blender': (2, 6, 6), 'blender': (2, 6, 6),
'location': "Node Editor Properties Panel (Ctrl-SPACE)", 'location': "Node Editor Properties Panel (Ctrl-SPACE)",
'description': "Nodes Efficiency Tools", 'description': "Nodes Efficiency Tools",
...@@ -32,6 +32,7 @@ bl_info = { ...@@ -32,6 +32,7 @@ bl_info = {
import bpy import bpy
from bpy.types import Operator, Panel, Menu from bpy.types import Operator, Panel, Menu
from bpy.props import FloatProperty, EnumProperty, BoolProperty from bpy.props import FloatProperty, EnumProperty, BoolProperty
from mathutils import Vector
################# #################
# rl_outputs: # rl_outputs:
...@@ -1091,6 +1092,67 @@ class SelectParentChildren(Operator, NodeToolBase): ...@@ -1091,6 +1092,67 @@ class SelectParentChildren(Operator, NodeToolBase):
return {'FINISHED'} 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 # P A N E L S
############################################################# #############################################################
...@@ -1113,9 +1175,11 @@ class EfficiencyToolsPanel(Panel, NodeToolBase): ...@@ -1113,9 +1175,11 @@ class EfficiencyToolsPanel(Panel, NodeToolBase):
box.menu(NodeAlignMenu.bl_idname, text="Align Nodes (Shift =)") box.menu(NodeAlignMenu.bl_idname, text="Align Nodes (Shift =)")
box.menu(CopyToSelectedMenu.bl_idname, text="Copy to Selected (Shift-C)") box.menu(CopyToSelectedMenu.bl_idname, text="Copy to Selected (Shift-C)")
box.operator(NodesClearLabel.bl_idname).option = True box.operator(NodesClearLabel.bl_idname).option = True
box.operator(DetachOutputs.bl_idname)
box.menu(AddReroutesMenu.bl_idname, text="Add Reroutes ( / )") box.menu(AddReroutesMenu.bl_idname, text="Add Reroutes ( / )")
box.menu(NodesSwapMenu.bl_idname, text="Swap Nodes (Shift-S)") box.menu(NodesSwapMenu.bl_idname, text="Swap Nodes (Shift-S)")
box.menu(LinkActiveToSelectedMenu.bl_idname, text="Link Active To Selected ( \\ )") box.menu(LinkActiveToSelectedMenu.bl_idname, text="Link Active To Selected ( \\ )")
box.operator(LinkToOutputNode.bl_idname)
############################################################# #############################################################
...@@ -1136,9 +1200,11 @@ class EfficiencyToolsMenu(Menu, NodeToolBase): ...@@ -1136,9 +1200,11 @@ class EfficiencyToolsMenu(Menu, NodeToolBase):
layout.menu(NodeAlignMenu.bl_idname, text="Align Nodes") layout.menu(NodeAlignMenu.bl_idname, text="Align Nodes")
layout.menu(CopyToSelectedMenu.bl_idname, text="Copy to Selected") layout.menu(CopyToSelectedMenu.bl_idname, text="Copy to Selected")
layout.operator(NodesClearLabel.bl_idname).option = True layout.operator(NodesClearLabel.bl_idname).option = True
layout.operator(DetachOutputs.bl_idname)
layout.menu(AddReroutesMenu.bl_idname, text="Add Reroutes") layout.menu(AddReroutesMenu.bl_idname, text="Add Reroutes")
layout.menu(NodesSwapMenu.bl_idname, text="Swap Nodes") layout.menu(NodesSwapMenu.bl_idname, text="Swap Nodes")
layout.menu(LinkActiveToSelectedMenu.bl_idname, text="Link Active To Selected") layout.menu(LinkActiveToSelectedMenu.bl_idname, text="Link Active To Selected")
layout.operator(LinkToOutputNode.bl_idname)
class MergeNodesMenu(Menu, NodeToolBase): class MergeNodesMenu(Menu, NodeToolBase):
...@@ -1510,6 +1576,10 @@ kmi_defs = ( ...@@ -1510,6 +1576,10 @@ kmi_defs = (
(ChangeMixFactor.bl_idname, 'ONE', True, True, True, (('option', 1.0),)), (ChangeMixFactor.bl_idname, 'ONE', True, True, True, (('option', 1.0),)),
# CLEAR LABEL (Alt L) # CLEAR LABEL (Alt L)
(NodesClearLabel.bl_idname, 'L', False, False, True, (('option', False),)), (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 PARENT/CHILDREN
# Select Children # Select Children
(SelectParentChildren.bl_idname, 'RIGHT_BRACKET', False, False, False, (('option', 'CHILD'),)), (SelectParentChildren.bl_idname, 'RIGHT_BRACKET', False, False, False, (('option', 'CHILD'),)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment