Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3408 from pypeclub/bugfix/houdini-vdb-bgeo-loadin…
Browse files Browse the repository at this point in the history
…g-updating-fix

Houdini: fix loading and updating vbd/bgeo sequences
  • Loading branch information
antirotor authored Jun 27, 2022
2 parents 927b1b8 + 8412fca commit 714c588
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
11 changes: 6 additions & 5 deletions openpype/hosts/houdini/plugins/load/load_bgeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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"])})
Expand Down
27 changes: 9 additions & 18 deletions openpype/hosts/houdini/plugins/load/load_vdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 <frame>.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("\\", "/")
Expand All @@ -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})

Expand Down

0 comments on commit 714c588

Please sign in to comment.