Skip to content

Commit

Permalink
Merge pull request #10 from nfa-vfxim/feature/issue-7/add-used-versio…
Browse files Browse the repository at this point in the history
…n-metadata-to-render

Added used publish version metadata
  • Loading branch information
mervinvb authored Jan 15, 2024
2 parents c33a10f + fe6dee3 commit 9e30c6d
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions python/tk_houdini_renderman/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,58 @@ def setup_aovs(self, node: hou.Node, show_notification: bool = True) -> bool:

md_artist = str(self.app.context.user["id"])

# Metadata get used publish versions
current_engine = sgtk.platform.current_engine()
breakdown_app = current_engine.apps["tk-multi-breakdown"]

if breakdown_app:
self.app.logger.debug(
"Getting used publish versions with tk-multi-breakdown."
)

used_versions = []

# Get list of breakdown items
published_items = breakdown_app.analyze_scene()

# Now loop over all items
for published_item in published_items:
# Get the latest version on disk
latest_version = breakdown_app.compute_highest_version(
published_item["template"], published_item["fields"]
)

fields = published_item["fields"]
entity_type = published_item["sg_data"]["entity"]["type"]

version = {
"version": published_item["sg_data"]["version_number"],
"latest_version": latest_version,
"type": entity_type,
}

if entity_type == "Shot":
version[
"name"
] = f"{fields['Sequence']} {fields['Shot']} {fields['Step']} {fields['name']}"
elif entity_type == "Asset":
version[
"name"
] = f"{fields['Asset']} {fields['Step']} {fields['name']}"
else:
version["name"] = "Undefined"

used_versions.append(version)

md_items.append(
MetaData("rmd_UsedPublishVersions", "string", json.dumps(used_versions))
)

else:
self.app.logger.debug(
"The app tk-multi-breakdown is not installed, skipping used publish version metadata."
)

self.app.logger.debug(
f"Setting up aovs for files: {', '.join([file.identifier.value for file in active_files])}"
)
Expand Down Expand Up @@ -796,15 +848,12 @@ def get_output_path(self, node: hou.Node, aov_name: str) -> str:
def get_output_paths(self, node: hou.Node) -> list[str]:
paths = []

print(node.path())

try:
output_files, active_files = self.get_active_files(node)
for file in active_files:
file: aov_file.OutputFile
if file.identifier == aov_file.OutputIdentifier.CRYPTOMATTE:
for crypto in file.options:
print(crypto.key)
if node.parm(crypto.key).eval():
paths.append(self.get_output_path(node, crypto.key))
else:
Expand Down

0 comments on commit 9e30c6d

Please sign in to comment.