Node editor : what's the better way to create straight paths ?
Node editor : what's the better way to create straight paths ?
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)