Skip to content

Commit

Permalink
Added functions for USD stage references
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesvink committed Oct 4, 2021
1 parent 219eaf2 commit 713a8aa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def init_app(self):
tk_multi_breakdown = self.import_module("tk_multi_breakdown")
cb = lambda: tk_multi_breakdown.show_dialog(self)
self.engine.register_command(
"Scene Breakdown...", cb, {"short_name": "breakdown"}
"Version Control...", cb, {"short_name": "breakdown"}
)

@property
Expand Down
37 changes: 31 additions & 6 deletions hooks/tk-houdini_scene_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,20 @@ def scan_scene(self):
alembic_nodes = hou.nodeType(hou.sopNodeTypeCategory(), "alembic").instances()

# get a tuple of all regular file nodes in the file
file_nodes_unfiltered = hou.nodeType(hou.sopNodeTypeCategory(), "file").instances()
file_nodes_unfiltered = hou.nodeType(
hou.sopNodeTypeCategory(), "file"
).instances()

reference_nodes = hou.nodeType(
hou.lopNodeTypeCategory(), "reference"
).instances()

# refine tuple of all regular file nodes to exclude file nodes inside locked digital asset
file_nodes = tuple(file_node for file_node in file_nodes_unfiltered if not file_node.isInsideLockedHDA())
file_nodes = tuple(
file_node
for file_node in file_nodes_unfiltered
if not file_node.isInsideLockedHDA()
)

# return an item for each alembic node found. the breakdown app will check
# the paths of each looking for a template match and a newer version
Expand All @@ -74,8 +84,15 @@ def scan_scene(self):
file_parm = file_node.parm("file")
file_path = os.path.normpath(file_parm.eval())

items.append({"node": file_node.path(), "type": "file", "path": file_path})

# search in all reference node
for reference_node in reference_nodes:
file_parm = reference_node.parm("filepath1")
file_path = os.path.normpath(file_parm.eval())

items.append(
{"node": file_node.path(), "type": "file", "path": file_path}
{"node": reference_node.path(), "type": "reference", "path": file_path}
)

return items
Expand Down Expand Up @@ -115,8 +132,8 @@ def update(self, items):
alembic_node.parm("fileName").set(file_path)

# update the file node file parameter to the new path
if node_type == 'file':
if node_type == "file":

frame_match_path = re.search(frame_pattern_path, file_path)

if frame_match_path:
Expand All @@ -128,4 +145,12 @@ def update(self, items):
engine.log_debug(
"Updating file node '%s' to: %s" % (node_path, file_path)
)
file_node.parm("file").set(file_path)
file_node.parm("file").set(file_path)

# update the reference node paramter to the new path
if node_type == "reference":
reference_node = hou.node(node_path)
engine.log_debug(
"Updating file node '%s' to: %s" % (node_path, file_path)
)
reference_node.parm("filepath1").set(file_path)

0 comments on commit 713a8aa

Please sign in to comment.