Skip to content

Commit

Permalink
Merge pull request #20 from mbrainerd/feature-538
Browse files Browse the repository at this point in the history
#538: sync framerange on new file operation.
  • Loading branch information
aparna-d2 authored Apr 6, 2018
2 parents 466d538 + f01a6dd commit 8426afb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
18 changes: 12 additions & 6 deletions hooks/tk-multi-workfiles2/scene_operation_tk-maya.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ def set_show_preferences(self, file_path, context):
# context.as_template_fields() doesn't contain {name}, {version}
file_template = context.sgtk.template_from_path(file_path)
if not file_template:
self.parent.logger.warning("Current file path doesn't conform to Shotgun template. "
"Not setting show default settings.")
warning_message = "Current file path doesn't conform to Shotgun template. " \
"Not setting show default settings."
self.parent.logger.warning(warning_message)
QtGui.QMessageBox.warning(None, "Show defaults not set", warning_message)
return

fields = file_template.get_fields(file_path)
Expand All @@ -143,8 +145,10 @@ def set_show_preferences(self, file_path, context):
try:
cmds.currentUnit(time="{}fps".format(show_prefs["show_settings"]["fps"]))
except KeyError as ke:
self.parent.logger.warning("Unable to find {} in show preferences. "
"Not setting fps.".format(ke))
warning_message = "Unable to find {} in show preferences. " \
"Not setting fps.".format(ke)
self.parent.logger.warning(warning_message)
QtGui.QMessageBox.warning(None, "FPS not set", warning_message)

# get resolution and set render defaults
try:
Expand All @@ -153,8 +157,10 @@ def set_show_preferences(self, file_path, context):
"output": "LAYERPLACEHOLDER"}) # output is alphanumeric
# replace with token <Layer>
except KeyError as ke:
self.parent.logger.warning("Unable to find {} in show preferences. "
"Not setting render defaults.".format(ke))
warning_message = "Unable to find {} in show preferences. " \
"Not setting render defaults.".format(ke)
self.parent.logger.warning(warning_message)
QtGui.QMessageBox.warning(None, "Render defaults not set", warning_message)
else:
fields.pop("extension") # remove ma as extension to apply default img ext
render_path = render_temp.apply_fields(fields).replace("LAYERPLACEHOLDER", "<Layer>")
Expand Down
27 changes: 27 additions & 0 deletions hooks/tk-multi-workfiles2/scene_operation_tk-nuke.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,36 @@ def execute(self, operation, file_path, context, parent_action, file_version, re
nuke.scriptClear()
if parent_action == "new_file":
self.set_show_preferences(context)
self.sync_frame_range()

return True

def sync_frame_range(self):
engine = self.parent.engine
if engine.context.entity is None:
# tk-multi-setframerange needs a context entity to work
warning_message = "Your current context does not have an entity " \
"(e.g. a current Shot, current Asset etc). \nNot syncing frame range."
self.parent.logger.warning(warning_message)
QtGui.QMessageBox.warning(None, "Context has no entity", warning_message)
return

try:
# get app
frame_range_app = engine.apps["tk-multi-setframerange"]
except KeyError as ke:
error_message = "Unable to find {} in {} at this time. " \
"Not syncing frame range automatically.".format(ke, engine.name)
self.parent.logger.error(error_message)
QtGui.QMessageBox.error(None, "Set Frame Range App unavailable", error_message)
else:
try:
frame_range_app.run_app()
except TankError as te:
warning_message = "{}. Not syncing frame range.".format(te)
self.parent.logger.warning(warning_message)
QtGui.QMessageBox.warning(None, "Entity has no in/out frame", warning_message)

def set_show_preferences(self, context):
fields = context.as_template_fields()

Expand Down

0 comments on commit 8426afb

Please sign in to comment.