this post was submitted on 12 Feb 2025
22 points (95.8% liked)

Blender

2858 readers
40 users here now

A community for users of the awesome, open source, free, animation, modeling, procedural generating, sculpting, texturing, compositing, and rendering software; Blender.

Rules:

  1. Be nice
  2. Constructive Criticism only
  3. If a render is photo realistic, please provide a wireframe or clay render

founded 2 years ago
MODERATORS
 

Hello yall ! I am asking for your opinion on node editing, more precisely on creating straight paths with reroute nodes.

I find the built-in way of creating straight paths with reroute quite weird. If I'm not mistaken, it is :

  • Click-drag to create the connection
  • Shift + Right-click-drag to create a reroute.
  • G and drag to place the reroute (repeat until path is made of 90° angles)

Now when it's time to clean up messy noodles, it makes sense : you don't need the first step and you can join multiple noodles with the Shift + Right-click-drag to go quicker. But when I create straight path from the start, I find it weird to first make the full path and then divide it.

I would have liked a feature to 'extrude' from reroute nodes so I can build the straight path step by step instead, so I made a small script to add this as a shortcut : when i press 'E', it adds a reroute connected to the last reroute/node selected. I'll try to add a gif to show what I mean, and I'll leave the code if anyone wants to try.

My question is : am I alone on this or does it make sense ? Did you too find the way reroute works a bit weird or did it always made perfect sense to you ? Or do you avoid straight paths entirely ? (Or is there some other way to work with reroutes that i'm not aware of ?)

Anyway, here is the code if needed (to use it, save it in a .py file, and in the Preferences/Addons tab, choose Install from disk and select your file) :

bl_info = {
    "name" : "Extrude Noodles",
    "blender" : (3, 60, 0),
    "category" : "Node",
}

import bpy

class NodeConnectedReroute(bpy.types.Operator):
    bl_idname = "node.add_connected_reroute"
    bl_label = "Add connected reroute (Extrude) V4"
    bl_options = {'REGISTER', 'UNDO'}
    
    
    def execute(self, context) :        
        # Get node tree
        nt = context.material.node_tree        
        # Get active node
        node = bpy.context.active_node
        
        # OPTION A - Create a not connected reroute
        # in case there is no active node or it's not selected or it has no outputs   
        if not node or not node.select or not node.outputs.keys() :
            bpy.ops.node.add_node(use_transform=True, type="NodeReroute")
            return bpy.ops.transform.translate('INVOKE_DEFAULT')
        
        # OPTION B - Create a reroute and link it to the active and selected node
        # Add a reroute and connect it to current node first output
        bpy.ops.node.add_node(use_transform=True, type="NodeReroute")
        reroute = bpy.context.active_node
        nt.links.new(reroute.inputs[0], node.outputs[0])
        
        return bpy.ops.transform.translate('INVOKE_DEFAULT') # Returns that calls for movement.

def menu_func(self, context) :
    self.layout.operator(NodeConnectedReroute.bl_idname)
    

# Store keymaps outside any function to access it any time
addon_keymaps = []

 # When addon is enabled
def register() :
    # Register the operator
    bpy.utils.register_class(NodeConnectedReroute)
    # Register its menu function in the correct menu
    bpy.types.NODE_MT_node.remove(menu_func)
    bpy.types.NODE_MT_node.append(menu_func)
    
    # Create addon map
    wm = bpy.context.window_manager
    # Check if keyconfigs are available
    kc = wm.keyconfigs.addon
    if kc :
        # Create a keymap in Node Editor context
        km = wm.keyconfigs.addon.keymaps.new(name="Node Editor", space_type='NODE_EDITOR')
        # Add a keymap item for simple extrude
        kmi = km.keymap_items.new(NodeConnectedReroute.bl_idname, 'E', 'PRESS')
        addon_keymaps.append((km, kmi))

# When addon is disabled
def unregister() : 
    # Do register in reverse order
    
    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)
    addon_keymaps.clear()
    
    bpy.utils.unregister_class(NodeConnectedReroute)
    bpy.types.NODE_MT_node.remove(menu_func)
top 2 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 20 hours ago (1 children)

What you did makes perfect sense, I personally just don't use reroutes so much and I don't use them your way. To avoid having to reroute wires around nodes I give up on aligning nodes to each other, instead I move them up/down in a way that allows wires going to further nodes to be more visible. Also if it's attribute, I often just duplicate attribute node and place it near the node that needs its value instead of using a single attribute node and connecting it to many nodes. What you're doing definitely looks more neat and clean.

[–] Takapapatapaka 1 points 9 hours ago

Yeah, duplicating attributes/Input nodes is nice way to solve a good part of the problem. Thanks for sharing your opinion !