Skip to content

Commit

Permalink
Added CopyExporter preset in Hiero settings for automatic renaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesvink committed Sep 27, 2020
1 parent 4f513d5 commit 95fd249
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
32 changes: 20 additions & 12 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2013 Shotgun Software Inc.
#
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

"""
Expand All @@ -27,6 +27,7 @@
import hiero.exporters

from hiero.exporters import FnExternalRender
from hiero.exporters import FnCopyExporter
from hiero.exporters import FnNukeShotExporter

# do not use tk import here, hiero needs the classes to be in their
Expand Down Expand Up @@ -57,7 +58,7 @@
HIERO_SUBSTITUTION_KEYWORDS = ["clip", "day", "DD", "event",
"ext", "filebase", "fileext", "filehead",
"filename", "filepadding", "fullbinpath", "fullday", "fullmonth",
"MM", "month", "project", "projectroot", "sequence", "shot",
"MM", "month", "project", "projectroot", "sequence", "shot",
"tk_version", "track", "user", "version", "YY", "YYYY"]


Expand Down Expand Up @@ -156,7 +157,7 @@ def _add_default_presets(self, overwrite):
self._old_AddDefaultPresets_fn(overwrite)

# Add Shotgun template
name = "Basic Shotgun Shot"
name = "NFA Shotgun Shot"
localpresets = [preset.name() for preset in hiero.core.taskRegistry.localPresets()]

# only add the preset if it is not already there - or if a reset to defaults is requested.
Expand All @@ -165,6 +166,7 @@ def _add_default_presets(self, overwrite):
plate_template = self.get_template("template_plate_path")
script_template = self.get_template("template_nuke_script_path")
render_template = self.get_template("template_render_path")
copy_template = self.get_template("template_copy_path")

# call the hook to translate them into hiero paths, using hiero keywords
plate_hiero_str = self.execute_hook("hook_translate_template", template=plate_template, output_type='plate')
Expand All @@ -176,29 +178,36 @@ def _add_default_presets(self, overwrite):
render_hiero_str = self.execute_hook("hook_translate_template", template=render_template, output_type='render')
self.log_debug("Translated %s --> %s" % (render_template, render_hiero_str))

copy_hiero_str = self.execute_hook("hook_translate_template", template=copy_template, output_type='copy')
self.log_debug("Translated %s --> %s" % (copy_template, copy_hiero_str))

# check so that no unknown keywords exist in the templates after translation
self._validate_hiero_export_template(plate_hiero_str)
self._validate_hiero_export_template(script_hiero_str)
self._validate_hiero_export_template(render_hiero_str)
self._validate_hiero_export_template(copy_hiero_str)

# and set the default properties to be based off of those templates

# Set the quicktime defaults per our hook
file_type, file_options = self.execute_hook("hook_get_quicktime_settings", for_shotgun=False)
properties = {
"exportTemplate": (
(script_hiero_str, ShotgunNukeShotPreset("", {"readPaths": [], "writePaths": []})),
(render_hiero_str, FnExternalRender.NukeRenderPreset("", {"file_type": "dpx", "dpx": {"datatype": "10 bit"}})),
(script_hiero_str, ShotgunNukeShotPreset("", {"readPaths": [ "02_source/{sequence}/{shot}/p{tk_version}/plates/{fileext}/{projectcode}_sc{sequence}_sh{shot}_plate_p{tk_version}.####.{fileext}",], "writePaths": []})),
(render_hiero_str, FnExternalRender.NukeRenderPreset("", {"file_type": "exr", "exr": {"datatype": "16 bit"}})),
(plate_hiero_str, ShotgunTranscodePreset("", {"file_type": file_type, file_type: file_options})),
(copy_hiero_str, FnCopyExporter.CopyPreset("", {})),
)
}
preset = ShotgunShotProcessorPreset(name, properties)
hiero.core.taskRegistry.removeProcessorPreset(name)
hiero.core.taskRegistry.addProcessorPreset(name, preset)



def _validate_hiero_export_template(self, template_str):
"""
Validate that a template_str only contains Hiero substitution keywords or custom
Validate that a template_str only contains Hiero substitution keywords or custom
keywords created via the resolve_custom_strings hook.
"""
# build list of valid tokens
Expand All @@ -208,7 +217,7 @@ def _validate_hiero_export_template(self, template_str):
# replace all tokens we know about in the template
for x in hiero_resolver_tokens:
template_str = template_str.replace(x, "")

# find any remaining {xyz} tokens in the template
regex = r"(?<={)[a-zA-Z_ 0-9]+(?=})"
key_names = re.findall(regex, template_str)
Expand All @@ -218,4 +227,3 @@ def _validate_hiero_export_template(self, template_str):
"or adjust the hook that converts a template to a hiero export "
"path to convert these fields into fixed strings or hiero "
"substitution tokens." % (template_str, ",".join(key_names) ) )

12 changes: 10 additions & 2 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ configuration:
hook_get_shot:
type: hook
description: "Called to return the shot to update cut information for.
The first argument is the Hiero export Task object. The second
The first argument is the Hiero export Task object. The second
argument is the hiero.core.TrackItem that is driving shot creation.
The third argument is a data dictionary that can be used to pass
The third argument is a data dictionary that can be used to pass
data between different calls to shot create.
The return value is a data dictionary for the shot, whose
Expand Down Expand Up @@ -205,6 +205,14 @@ configuration:
required_fields: []
optional_fields: "*"

template_copy_path:
type: template
description: "A reference to a template which specifies the directory to
publish shot plates to. The translate template hook must
understand how to translate this to Hiero keywords."
required_fields: []
optional_fields: "*"

template_nuke_script_path:
type: template
description: "A reference to a template which specifies what published
Expand Down

0 comments on commit 95fd249

Please sign in to comment.