Node Wrangler : Align Nodes operator disregards selection when used on frames #99904

Open
opened 2022-07-22 10:27:25 +02:00 by ChameleonScales · 5 comments

System Information
Operating system: Linux-5.10.0-16-amd64-x86_64-with-glibc2.31 64 Bits
Graphics card: NVIDIA GeForce GTX 1660/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.129.06

Blender Version
Broken: version: 3.2.0, branch: master, commit date: 2022-06-08 10:22, hash: blender/blender@e05e1e3691
Worked: I don't remember it ever working (been using Blender since 2.7x).

Short description of error
if a frame node is selected, the Align Nodes button moves all the nodes in the tree, including those that aren't selected.

Exact steps for others to reproduce the error
From the startup file:

  • open any node editor
  • add any node
  • add an empty frame node
  • select only the frame
  • in the Node Wrangler panel, click on Align Nodes : all the nodes that aren't selected move too

Note : This other issue probably needs to be solved first in order to fix this one

**System Information** Operating system: Linux-5.10.0-16-amd64-x86_64-with-glibc2.31 64 Bits Graphics card: NVIDIA GeForce GTX 1660/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.129.06 **Blender Version** Broken: version: 3.2.0, branch: master, commit date: 2022-06-08 10:22, hash: `blender/blender@e05e1e3691` Worked: I don't remember it ever working (been using Blender since 2.7x). **Short description of error** if a frame node is selected, the Align Nodes button moves all the nodes in the tree, including those that aren't selected. **Exact steps for others to reproduce the error** From the startup file: - open any node editor - add any node - add an empty frame node - select only the frame - in the Node Wrangler panel, click on Align Nodes : all the nodes that aren't selected move too **Note :** [This other issue ](https://developer.blender.org/T99903) probably needs to be solved first in order to fix this one

Added subscriber: @ChameleonScales

Added subscriber: @ChameleonScales
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Omar Emara changed title from Node Wrangler : Align Nodes is broken when used on frames to Node Wrangler : Align Nodes operator disregards selection when used on frames 2022-07-22 11:57:46 +02:00
Contributor

What your describing here isn't a bug with frames, but moreso just weird unintuitive behavior from the operator itself.

Looking at the code for the NWAlignNodes operator, it ignores frames during its execution:

    def execute(self, context):
        nodes, links = get_nodes_links(context)
        margin = self.margin

        selection = []
        for node in nodes:
            if node.select and node.type != 'FRAME':
                selection.append(node)

So selecting a frame like you described results in an empty selection. The choice I personally find weird is that if no nodes are selected, it uses all nodes as a selection:

        # If no nodes are selected, align all nodes
        active_loc = None
        if not selection:
            selection = nodes

That's why selecting only a frame moves nodes you haven't selected, from the operator's perspective, nothing has been selected so it simply aligns all the nodes in the nodetree.

At least it tries to, a separate but more general bug is happening here where nodes don't get properly aligned when they don't share the same frame, hence why the final result looks random instead of being aligned as one line.

What your describing here isn't a bug with frames, but moreso just weird unintuitive behavior from the operator itself. Looking at the code for the NWAlignNodes operator, it ignores frames during its execution: ```python def execute(self, context): nodes, links = get_nodes_links(context) margin = self.margin selection = [] for node in nodes: if node.select and node.type != 'FRAME': selection.append(node) ``` So selecting a frame like you described results in an empty selection. The choice I personally find weird is that if no nodes are selected, it uses all nodes as a selection: ```python # If no nodes are selected, align all nodes active_loc = None if not selection: selection = nodes ``` That's why selecting only a frame moves nodes you haven't selected, from the operator's perspective, nothing has been selected so it simply aligns all the nodes in the nodetree. At least it tries to, a separate but more general bug is happening here where nodes don't get properly aligned when they don't share the same frame, hence why the final result looks random instead of being aligned as one line.
Contributor

Addressing this issue would be separated into two parts:

1.) Fixing the general bug of the operator not calculating positions properly when multiple frames are involved. Though this is a more secondary concern, as this isn't related to the selection being ignored, this just fixes the nodes being seemingly placed at random when framed nodes are aligned.

2.) Remove the part where the operator aligns all nodes when none are selected. This is the more immediate concern in this issue. It doesn't seem to be intuitive behavior as no nodes being aligned is probably more expected when no nodes have been selected.

Secondly, if a user wanted to align all nodes, they could easily select all nodes with the 'A' hotkey before calling this operator, so no actual functionality is being lost if the operator just ends execution early when no nodes have been selected.

Addressing this issue would be separated into two parts: 1.) Fixing the general bug of the operator not calculating positions properly when multiple frames are involved. Though this is a more secondary concern, as this isn't related to the selection being ignored, this just fixes the nodes being seemingly placed at random when framed nodes are aligned. 2.) Remove the part where the operator aligns all nodes when none are selected. This is the more immediate concern in this issue. It doesn't seem to be intuitive behavior as no nodes being aligned is probably more expected when no nodes have been selected. Secondly, if a user wanted to align all nodes, they could easily select all nodes with the 'A' hotkey before calling this operator, so no actual functionality is being lost if the operator just ends execution early when no nodes have been selected.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#99904
No description provided.