implemented setting project fps

This commit is contained in:
wijnand 2018-06-28 17:52:39 +02:00
parent 675dcd83c8
commit d43a80945d
3 changed files with 44 additions and 3 deletions

View file

@ -247,3 +247,23 @@ def collect_container_metadata(container):
return {}
return hostlib.get_additional_data(container)
def get_project_fps():
"""Returns project's FPS, if not found will return 25 by default
Returns:
int, float
"""
project_name = io.active_project()
project = io.find_one({"name": project_name,
"type": "project"},
projection={"config.fps": True})
config = project.get("config", None)
assert config, "This is a bug"
fps = config.get("fps", 25)
return fps

View file

@ -2,8 +2,7 @@ import os
import logging
import weakref
from maya import utils
from maya import cmds
from maya import utils, cmds
from avalon import api as avalon, pipeline, maya
from pyblish import api as pyblish
@ -94,6 +93,7 @@ def on_init(_):
from .customize import override_component_mask_commands
safe_deferred(override_component_mask_commands)
safe_deferred(lib.set_project_fps)
def on_save(_):
@ -119,6 +119,9 @@ def on_open(_):
from avalon.vendor.Qt import QtWidgets
from ..widgets import popup
# Ensure scene's FPS is set to project config
lib.set_project_fps()
# Update current task for the current scene
update_task_from_path(cmds.file(query=True, sceneName=True))

View file

@ -13,7 +13,7 @@ from collections import OrderedDict, defaultdict
from maya import cmds, mel
from avalon import api, maya, io, pipeline
from cb.utils.maya import core
from colorbleed import lib
import cb.utils.maya.context
@ -1292,3 +1292,21 @@ def get_id_from_history(node):
_id = get_id(similar_node)
if _id:
return _id
def set_project_fps():
"""Set FPS from project configuration"""
fps = lib.get_project_fps()
if not isinstance(fps, (int, float)):
raise ValueError("Set value for project's FPS is not a number. "
"Only accepts floats and integers")
if int(fps) == 24:
cmds.currentUnit(time="film")
log.info("Updated FPS to 24 (film)")
elif int(fps) == 25:
cmds.currentUnit(time="pal")
log.info("Updated FPS to 25 (pal)")
else:
raise RuntimeError("Cannot translate FPS: `%s`" % fps)