From 5d70a5128585b94b42a1f1384d88c1adfcd8fc6d Mon Sep 17 00:00:00 2001 From: Aurore LAFAURIE Date: Fri, 26 Apr 2024 15:56:26 +0200 Subject: [PATCH] [core] Set internal attributes when copy/pasting nodes --- meshroom/core/graph.py | 1 + meshroom/core/node.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py index 099a8ad6..a2039e72 100644 --- a/meshroom/core/graph.py +++ b/meshroom/core/graph.py @@ -617,6 +617,7 @@ class Graph(BaseObject): attributes = {} attributes.update(data[key].get("inputs", {})) attributes.update(data[key].get("outputs", {})) + attributes.update(data[key].get("internalInputs", {})) node = Node(nodeType, position=position[positionCnt], **attributes) self._addNode(node, key) diff --git a/meshroom/core/node.py b/meshroom/core/node.py index c7287a23..6a1d016c 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -1258,6 +1258,7 @@ class Node(BaseNode): self.attributesPerUid[uidIndex].add(attr) self.setAttributeValues(kwargs) + self.setInternalAttributeValues(kwargs) self.optionalCallOnDescriptor("onNodeCreated") def optionalCallOnDescriptor(self, methodName, *args, **kwargs): @@ -1270,6 +1271,9 @@ class Node(BaseNode): def setAttributeValues(self, values): # initialize attribute values for k, v in values.items(): + if not self.hasAttribute(k): + # skip missing attributes + continue attr = self.attribute(k) if attr.isInput: attr.value = v @@ -1287,6 +1291,15 @@ class Node(BaseNode): except ValueError: pass + def setInternalAttributeValues(self, values): + # initialize internal attribute values + for k, v in values.items(): + if not self.hasInternalAttribute(k): + # skip missing attributes + continue + attr = self.internalAttribute(k) + attr.value = v + def upgradeInternalAttributeValues(self, values): # initialize internal attibute values for k, v in values.items():