Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions client/ayon_nuke/plugins/load/load_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ def update(self, container, context):
# getting file path
file = get_representation_path(repre_entity).replace("\\", "/")

with maintained_selection():
camera_node = container["node"]
camera_node['selected'].setValue(True)

camera_node = container["node"]
selected = camera_node["selected"]

with maintained_selection(
# exclude from selection, since we will be recreating the node
# which will invalidate the reference to the object in memory
exclude_nodes=[camera_node],
):
# collect input output dependencies
dependencies = camera_node.dependencies()
dependent = camera_node.dependent()
Expand All @@ -161,11 +165,12 @@ def update(self, container, context):
# not adding animation keys properly
xpos = camera_node.xpos()
ypos = camera_node.ypos()
camera_node.selectOnly()
nuke.nodeCopy("%clipboard%")
camera_name = camera_node.name()
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

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

raise RuntimeError("Failed to paste camera node")
camera_node.setXYpos(xpos, ypos)

# link to original input nodes
Expand All @@ -178,6 +183,8 @@ def update(self, container, context):
if camera_node is dpcy), 0)
d.setInput(index, camera_node)

camera_node["selected"].setValue(selected)

# color node by correct color by actual version
self.node_version_color(
context["project"]["name"], version_entity, camera_node
Expand Down
Loading