Fix FPS check for asset overridden values (and simplify getting required asset fps)

This commit is contained in:
Roy Nieterau 2018-09-13 18:17:54 +02:00
parent 4d763157d3
commit b2ca58723f
3 changed files with 22 additions and 12 deletions

View file

@ -252,7 +252,7 @@ def collect_container_metadata(container):
return hostlib.get_additional_data(container)
def get_project_fps():
def get_asset_fps():
"""Returns project's FPS, if not found will return 25 by default
Returns:
@ -260,10 +260,20 @@ def get_project_fps():
"""
data = get_project_data()
fps = data.get("fps", 25.0)
key = "fps"
return fps
# FPS from asset data (if set)
asset_data = get_asset_data()
if key in asset_data:
return asset_data[key]
# FPS from project data (if set)
project_data = get_project_data()
if key in project_data:
return project_data[key]
# Fallback to 25 FPS
return 25.0
def get_project_data():
@ -298,7 +308,7 @@ def get_asset_data(asset=None):
Returns:
dict
"""
asset_name = asset or avalon.api.Session["AVALON_ASSET"]
document = io.find_one({"name": asset_name,
"type": "asset"})

View file

@ -1472,8 +1472,7 @@ def validate_fps():
"""
asset_data = lib.get_asset_data()
fps = asset_data.get("fps", lib.get_project_fps()) # can be int or float
fps = lib.get_asset_fps()
current_fps = mel.eval('currentTimeUnitToFPS()') # returns float
if current_fps != fps:

View file

@ -16,11 +16,12 @@ class ValidateMayaUnits(pyblish.api.ContextPlugin):
def process(self, context):
# Collected units
linearunits = context.data('linearUnits')
angularunits = context.data('angularUnits')
fps = context.data['fps']
project_fps = lib.get_project_fps()
asset_fps = lib.get_asset_fps()
self.log.info('Units (linear): {0}'.format(linearunits))
self.log.info('Units (angular): {0}'.format(angularunits))
@ -32,7 +33,7 @@ class ValidateMayaUnits(pyblish.api.ContextPlugin):
assert angularunits and angularunits == 'deg', ("Scene angular units "
"must be degrees")
assert fps and fps == project_fps, "Scene must be %s FPS" % project_fps
assert fps and fps == asset_fps, "Scene must be %s FPS" % asset_fps
@classmethod
def repair(cls):
@ -49,5 +50,5 @@ class ValidateMayaUnits(pyblish.api.ContextPlugin):
cls.log.debug(current_linear)
cls.log.info("Setting time unit to match project")
project_fps = lib.get_project_fps()
mayalib.set_scene_fps(project_fps)
asset_fps = lib.get_asset_fps()
mayalib.set_scene_fps(asset_fps)