Skip to content

Fix/camera selection - #329

Open
vincentullmann wants to merge 2 commits into
ynput:developfrom
straylondon:fix/camera_selection
Open

Fix/camera selection#329
vincentullmann wants to merge 2 commits into
ynput:developfrom
straylondon:fix/camera_selection

Conversation

@vincentullmann

Copy link
Copy Markdown
Contributor

Changelog Description

fix an issue where updating cameras could cause other nodes to be copied or fail if the depending on the current seleciton

Additional review information

alternative solution: We remove the copy/paste workaround.
I'm not sure what exactly the workaround is for, so I cannot comment on it

Testing notes 1):

  1. import a camera
  2. select the camera node
  3. open the "AYON Scene Inventory"
  4. change the version
  5. observe a A PythonObject is not attached to a node. exeption
Version update to 'v008' failed with the following error:
A PythonObject is not attached to a node.
image

Explanation:

the maintained_selection context stores a list of selected nodes, including the camera node that is being updated
lines 164-167 cuts and pastes the node invalidating the python object referenced in the context manager

nuke.nodeCopy("%clipboard%")
camera_name = camera_node.name()
nuke.delete(camera_node)
nuke.nodePaste("%clipboard%")

How this PR fixes it:

Testing notes 2):

  1. import a camera
  2. select any other nodes
  3. open the "AYON Scene Inventory"
  4. change the version
  5. the other nodes will be copy/pasted
Peek.2026-07-10.10-53.mp4

Explanation:

How this PR fixes it:

using node.selectOnly() to ensure the camera is the only object getting copied
https://github.com/straylondon/ayon-nuke/blob/8939f315289acdebe39a9cba50ca01f5eb4bf503/client/ayon_nuke/plugins/load/load_camera.py#L168

nuke.nodePaste("%clipboard%")
camera_node = nuke.toNode(camera_name)
camera_node = nuke.nodePaste("%clipboard%")
if not camera_node:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is technically unrelated, but my ide kept shouting at me that camera_node could be None

nuke.delete(camera_node)
nuke.nodePaste("%clipboard%")
camera_node = nuke.toNode(camera_name)
camera_node = nuke.nodePaste("%clipboard%")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also not directly related to the issue, but given that we're using .selectOnly() earlier, we now know for sure that the return value of nuke.nodePaste will be that exact node.

So I figured that using the return value would be cleaner than looking it up via the name

@BigRoy

BigRoy commented Jul 10, 2026

Copy link
Copy Markdown
Member

alternative solution: We remove the copy/paste workaround.
I'm not sure what exactly the workaround is for, so I cannot comment on it

@jakubjezek001 @moonyuet any chance you may know?

Can we have maintained_selection silently ignore the objects that turned invalid instead without having to explicitly exclude them. I suppose we could just debug log then which I'd prefer honestly.

@BigRoy
BigRoy requested a review from jakubjezek001 July 10, 2026 10:19
@BigRoy BigRoy added type: bug Something isn't working sponsored This is directly sponsored by a client or community member labels Jul 10, 2026
@vincentullmann

Copy link
Copy Markdown
Contributor Author

made a PR for an alternative option, which would be to remove the copy/paste workaround
#330

@vincentullmann

vincentullmann commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Can we have maintained_selection silently ignore the objects that turned invalid instead without having to explicitly exclude them. I suppose we could just debug log then which I'd prefer honestly.

@BigRoy
yes, could do that too #331
I'd still keep this (or the alternative pr) due to the second bug described in "Testing notes 2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sponsored This is directly sponsored by a client or community member type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants