diff --git a/openpype/hosts/houdini/plugins/load/load_bgeo.py b/openpype/hosts/houdini/plugins/load/load_bgeo.py index a463d513832..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,15 +63,15 @@ 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 - print("single") else: filename = re.sub(r"(.*)\.(\d+)\.(bgeo.*)", "\\1.$F4.\\3", path) @@ -94,9 +95,9 @@ def update(self, container, representation): # Update the file path file_path = get_representation_path(representation) - file_path = self.format_path(file_path) + file_path = self.format_path(file_path, representation) - 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..c558a7a0e7a 100644 --- a/openpype/hosts/houdini/plugins/load/load_vdb.py +++ b/openpype/hosts/houdini/plugins/load/load_vdb.py @@ -40,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)}) + file_node.setParms( + {"file": self.format_path(self.fname, context["representation"])}) # Set display on last node file_node.setDisplayFlag(True) @@ -57,30 +58,20 @@ def load(self, context, name=None, namespace=None, data=None): suffix="", ) - def format_path(self, path): + @staticmethod + 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. - 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 +91,7 @@ def update(self, container, representation): # Update the file path file_path = get_representation_path(representation) - file_path = self.format_path(file_path) + file_path = self.format_path(file_path, representation) file_node.setParms({"file": file_path})