Preserve placeholder connections when resolving to multiple clips#277
Preserve placeholder connections when resolving to multiple clips#277jakubjezek001 wants to merge 7 commits into
Conversation
When multiple clips are loaded without explicit "Input"/"Output" nodes, fall back to the last connectable node to preserve upstream/downstream connections. Also improve docstring formatting.
|
closed by accindent |
There was a problem hiding this comment.
Pull request overview
Improves Nuke Loader Placeholder behavior when it resolves to multiple clips by attempting to preserve the original node-graph connections (upstream/downstream) instead of leaving all loaded nodes disconnected.
Changes:
- Updates
_set_loaded_connectionsto add fallback logic whenget_group_io_nodes()can’t find explicitly named “Input”/“Output” nodes for multi-clip loads. - Adjusts the method docstring/comment formatting for clarity.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…olved-connected-nodes
moonyuet
left a comment
There was a problem hiding this comment.
Works well for the load placeholder with clip loader
https://github.com/user-attachments/assets/aa609a5c-7613-4eb4-bce5-e86ef6556be6
It also works with load geo(input and output nodes).
Recording.2026-06-26.200953.mp4
|
What's the status here? @jakubjezek001 |
…olved-connected-nodes
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…olved-connected-nodes
| if input_node is None: | ||
| input_candidates = [ | ||
| n for n in connectable if n.maxInputs() > 0] | ||
| input_node = ( | ||
| input_candidates[0] if input_candidates else None) | ||
|
|
||
| if output_node is None: | ||
| output_candidates = [ | ||
| n for n in connectable if n.maxOutputs() > 0] | ||
| output_node = ( | ||
| output_candidates[0] if output_candidates else None) |
There was a problem hiding this comment.
If you load a group that has say 5 nodes, and they are connected in one stream, like A-B-C-D-E. The input would be A, the output would be E. Right?
In this logic here, the input and output would be A - because it allows more inputs and outputs than zero and has the first name (sorted). I'm still confused by this logic.
It should really be that we prefer nodes that are at the start of the graph, e.g. have no inputs but do have outputs. (so they must be somewhere at the start of it) The same goes for outputs, it must be a node that preferably has no output connections (within the loaded nodes), allows to have outputs and if there are two nodes for which this is true prefer the one that does have input connections. So that if for whatever reason you load a group that has a separate floating node C, we'd still take the one at the end of a stream of nodes:
A-B
C
☝️ pick B?
Or what's the reasoning you're after @jakubjezek001 ?
There was a problem hiding this comment.
before it was not connecting any node by mistake. So if placeholder was connected and was resolving in multiple loadable containers - before it would not connect anything at all. But now after the fix it will connect at least single loaded node.
Try it and will see.
There was a problem hiding this comment.
It may work consistently for a single node, but not for a graph of nodes as I'm trying to explain. If we're solving just the single node case - then the logic should consider it's only a single node. Then no need for the sorting and iterating. Then just:
if len(nodes) == 1:
node = nodes[0]
if node.maxInputs() > 0:
input_node = node
if node.maxOutputs() > 0:
output_node = node
Right?
Changelog Description
When a Loader Placeholder resolves to multiple clips without explicit "Input"/"Output" nodes, the system now preserves the original upstream and downstream connections by falling back to the last connectable node. Previously, placeholders resolving to multiple items would disconnect from the node graph, leaving all loaded clips floating. This fix ensures the first resolved item maintains the placeholder's original connections while additional items remain unconnected as intended.
The change addresses the root cause where
get_group_io_nodes()returnsNonefor both input/output when multiple clips lack specifically named IO nodes. The fallback logic identifies connectable nodes (those with available inputs or outputs) and uses the last one to maintain graph connectivity.Additional info
The fix modifies the
_set_loaded_connectionsmethod in the placeholder loader to include fallback logic when IO nodes are unavailable:maxInputs() > 0ormaxOutputs() > 0Testing notes:
Dependency
Close #109
AY-7741