From 3b69876754300a51bf7a4927c3d5ce588ec6897c Mon Sep 17 00:00:00 2001 From: wijnand Date: Thu, 5 Jul 2018 15:05:10 +0200 Subject: [PATCH] added before save function --- colorbleed/maya/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/colorbleed/maya/__init__.py b/colorbleed/maya/__init__.py index b4c0809020..da56fb973b 100644 --- a/colorbleed/maya/__init__.py +++ b/colorbleed/maya/__init__.py @@ -2,7 +2,7 @@ import os import logging import weakref -from maya import utils, cmds, mel +from maya import utils, cmds, mel, OpenMaya as om from avalon import api as avalon, pipeline, maya from pyblish import api as pyblish @@ -37,6 +37,8 @@ def install(): avalon.on("save", on_save) avalon.on("open", on_open) + avalon.before("save", before_save_check) + log.info("Overriding existing event 'taskChanged'") override_event("taskChanged", on_task_changed) @@ -95,6 +97,11 @@ def on_init(_): safe_deferred(override_component_mask_commands) +def before_save_check(return_code, _): + """Run validation for scene's FPS prior to saving""" + return lib.validate_fps() + + def on_save(_): """Automatically add IDs to new nodes @@ -112,8 +119,6 @@ def on_save(_): for node, new_id in lib.generate_ids(nodes): lib.set_id(node, new_id, overwrite=False) - lib.validate_fps() - def on_open(_): """On scene open let's assume the containers have changed."""