From ae0427bbad4db877472799b207cf1db206eadd76 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Fri, 24 Jun 2022 16:49:37 +0200 Subject: [PATCH 1/2] :bug: fix loading and updating vbd/bgeo sequences --- .../hosts/houdini/plugins/load/load_bgeo.py | 6 ++--- .../hosts/houdini/plugins/load/load_vdb.py | 27 +++++++------------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/openpype/hosts/houdini/plugins/load/load_bgeo.py b/openpype/hosts/houdini/plugins/load/load_bgeo.py index a463d513832..1c0cb81bee0 100644 --- a/openpype/hosts/houdini/plugins/load/load_bgeo.py +++ b/openpype/hosts/houdini/plugins/load/load_bgeo.py @@ -70,7 +70,6 @@ def format_path(path, is_sequence): # The path is either a single file or sequence in a folder. if not is_sequence: filename = path - print("single") else: filename = re.sub(r"(.*)\.(\d+)\.(bgeo.*)", "\\1.$F4.\\3", path) @@ -94,9 +93,10 @@ def update(self, container, representation): # Update the file path file_path = get_representation_path(representation) - file_path = self.format_path(file_path) + is_sequence = bool(representation["context"].get("frame")) + file_path = self.format_path(file_path, is_sequence) - file_node.setParms({"fileName": file_path}) + file_node.setParms({"file": file_path}) # Update attribute node.setParms({"representation": str(representation["_id"])}) diff --git a/openpype/hosts/houdini/plugins/load/load_vdb.py b/openpype/hosts/houdini/plugins/load/load_vdb.py index 9455b76b89f..efbac334ab6 100644 --- a/openpype/hosts/houdini/plugins/load/load_vdb.py +++ b/openpype/hosts/houdini/plugins/load/load_vdb.py @@ -31,6 +31,7 @@ def load(self, context, name=None, namespace=None, data=None): # Create a new geo node container = obj.createNode("geo", node_name=node_name) + is_sequence = bool(context["representation"]["context"].get("frame")) # Remove the file node, it only loads static meshes # Houdini 17 has removed the file node from the geo node @@ -40,7 +41,7 @@ def load(self, context, name=None, namespace=None, data=None): # Explicitly create a file node file_node = container.createNode("file", node_name=node_name) - file_node.setParms({"file": self.format_path(self.fname)}) + file_node.setParms({"file": self.format_path(self.fname, is_sequence)}) # Set display on last node file_node.setDisplayFlag(True) @@ -57,30 +58,19 @@ def load(self, context, name=None, namespace=None, data=None): suffix="", ) - def format_path(self, path): + @staticmethod + def format_path(path, is_sequence): """Format file path correctly for single vdb or vdb sequence.""" if not os.path.exists(path): raise RuntimeError("Path does not exist: %s" % path) # The path is either a single file or sequence in a folder. - is_single_file = os.path.isfile(path) - if is_single_file: + if not is_sequence: filename = path else: - # The path points to the publish .vdb sequence folder so we - # find the first file in there that ends with .vdb - files = sorted(os.listdir(path)) - first = next((x for x in files if x.endswith(".vdb")), None) - if first is None: - raise RuntimeError( - "Couldn't find first .vdb file of " - "sequence in: %s" % path - ) + filename = re.sub(r"(.*)\.(\d+)\.vdb$", "\\1.$F4.vdb", path) - # Set .vdb to $F.vdb - first = re.sub(r"\.(\d+)\.vdb$", ".$F.vdb", first) - - filename = os.path.join(path, first) + filename = os.path.join(path, filename) filename = os.path.normpath(filename) filename = filename.replace("\\", "/") @@ -100,7 +90,8 @@ def update(self, container, representation): # Update the file path file_path = get_representation_path(representation) - file_path = self.format_path(file_path) + is_sequence = bool(representation["context"].get("frame")) + file_path = self.format_path(file_path, is_sequence) file_node.setParms({"file": file_path}) From 8412fca0b1d7786417623770f3bb866a732154be Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Fri, 24 Jun 2022 17:41:44 +0200 Subject: [PATCH 2/2] :recycle: refactor format function --- openpype/hosts/houdini/plugins/load/load_bgeo.py | 9 +++++---- openpype/hosts/houdini/plugins/load/load_vdb.py | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/openpype/hosts/houdini/plugins/load/load_bgeo.py b/openpype/hosts/houdini/plugins/load/load_bgeo.py index 1c0cb81bee0..b298d423bc4 100644 --- a/openpype/hosts/houdini/plugins/load/load_bgeo.py +++ b/openpype/hosts/houdini/plugins/load/load_bgeo.py @@ -44,7 +44,8 @@ def load(self, context, name=None, namespace=None, data=None): # Explicitly create a file node file_node = container.createNode("file", node_name=node_name) - file_node.setParms({"file": self.format_path(self.fname, is_sequence)}) + file_node.setParms( + {"file": self.format_path(self.fname, context["representation"])}) # Set display on last node file_node.setDisplayFlag(True) @@ -62,11 +63,12 @@ def load(self, context, name=None, namespace=None, data=None): ) @staticmethod - def format_path(path, is_sequence): + def format_path(path, representation): """Format file path correctly for single bgeo or bgeo sequence.""" if not os.path.exists(path): raise RuntimeError("Path does not exist: %s" % path) + is_sequence = bool(representation["context"].get("frame")) # The path is either a single file or sequence in a folder. if not is_sequence: filename = path @@ -93,8 +95,7 @@ def update(self, container, representation): # Update the file path file_path = get_representation_path(representation) - is_sequence = bool(representation["context"].get("frame")) - file_path = self.format_path(file_path, is_sequence) + file_path = self.format_path(file_path, representation) file_node.setParms({"file": file_path}) diff --git a/openpype/hosts/houdini/plugins/load/load_vdb.py b/openpype/hosts/houdini/plugins/load/load_vdb.py index efbac334ab6..c558a7a0e7a 100644 --- a/openpype/hosts/houdini/plugins/load/load_vdb.py +++ b/openpype/hosts/houdini/plugins/load/load_vdb.py @@ -31,7 +31,6 @@ def load(self, context, name=None, namespace=None, data=None): # Create a new geo node container = obj.createNode("geo", node_name=node_name) - is_sequence = bool(context["representation"]["context"].get("frame")) # Remove the file node, it only loads static meshes # Houdini 17 has removed the file node from the geo node @@ -41,7 +40,8 @@ def load(self, context, name=None, namespace=None, data=None): # Explicitly create a file node file_node = container.createNode("file", node_name=node_name) - file_node.setParms({"file": self.format_path(self.fname, is_sequence)}) + file_node.setParms( + {"file": self.format_path(self.fname, context["representation"])}) # Set display on last node file_node.setDisplayFlag(True) @@ -59,11 +59,12 @@ def load(self, context, name=None, namespace=None, data=None): ) @staticmethod - def format_path(path, is_sequence): + def format_path(path, representation): """Format file path correctly for single vdb or vdb sequence.""" if not os.path.exists(path): raise RuntimeError("Path does not exist: %s" % path) + is_sequence = bool(representation["context"].get("frame")) # The path is either a single file or sequence in a folder. if not is_sequence: filename = path @@ -90,8 +91,7 @@ def update(self, container, representation): # Update the file path file_path = get_representation_path(representation) - is_sequence = bool(representation["context"].get("frame")) - file_path = self.format_path(file_path, is_sequence) + file_path = self.format_path(file_path, representation) file_node.setParms({"file": file_path})