From 44aede0cc45adb7ba9c1cd577d3d11739ef5c483 Mon Sep 17 00:00:00 2001 From: wijnand Date: Thu, 28 Jun 2018 18:36:52 +0200 Subject: [PATCH] added fps check to on_save --- colorbleed/maya/__init__.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/colorbleed/maya/__init__.py b/colorbleed/maya/__init__.py index 008d5229ce..60fb897c46 100644 --- a/colorbleed/maya/__init__.py +++ b/colorbleed/maya/__init__.py @@ -2,14 +2,15 @@ import os import logging import weakref -from maya import utils, cmds +from maya import utils, cmds, mel from avalon import api as avalon, pipeline, maya from pyblish import api as pyblish from ..lib import ( update_task_from_path, - any_outdated + any_outdated, + get_project_fps ) from . import menu from . import lib @@ -112,6 +113,29 @@ def on_save(_): for node, new_id in lib.generate_ids(nodes): lib.set_id(node, new_id, overwrite=False) + # Valid FPS + current_fps = mel.eval('currentTimeUnitToFPS()') # returns float + fps = get_project_fps() + if fps != current_fps: + + from avalon.vendor.Qt import QtWidgets + from ..widgets import popup + + # Find maya main window + top_level_widgets = {w.objectName(): w for w in + QtWidgets.QApplication.topLevelWidgets()} + + parent = top_level_widgets.get("MayaWindow", None) + + dialog = popup.Popup(parent=parent) + dialog.setWindowTitle("Maya scene not in line with project") + dialog.setMessage("The FPS is out of sync, please fix") + # Set new text for button (could be an optional argument for the popup) + dialog.widgets["show"].setText("Fix") + dialog.on_show.connect(lib.set_project_fps) + + dialog.show() + def on_open(_): """On scene open let's assume the containers have changed."""