diff --git a/client/ayon_core/hosts/maya/api/lib.py b/client/ayon_core/hosts/maya/api/lib.py index 3a29fe433b..7a9ec933d3 100644 --- a/client/ayon_core/hosts/maya/api/lib.py +++ b/client/ayon_core/hosts/maya/api/lib.py @@ -19,6 +19,7 @@ from maya import cmds, mel from maya.api import OpenMaya +from ayon_api import get_task_by_name from ayon_core.client import ( get_project, get_asset_by_name, @@ -2614,17 +2615,24 @@ def reset_scene_resolution(): project_name = get_current_project_name() project_doc = get_project(project_name) project_data = project_doc["data"] - asset_data = get_current_project_asset()["data"] + asset_data_root = get_current_project_asset() + asset_data = asset_data_root["data"] + + task_name = get_current_task_name() + task_entity = get_task_by_name( + project_name, asset_data_root["_id"], task_name) # Set project resolution width_key = "resolutionWidth" height_key = "resolutionHeight" pixelAspect_key = "pixelAspect" - width = asset_data.get(width_key, project_data.get(width_key, 1920)) - height = asset_data.get(height_key, project_data.get(height_key, 1080)) - pixelAspect = asset_data.get(pixelAspect_key, - project_data.get(pixelAspect_key, 1)) + # Get frame information from task entity + # NOTE: If there is no task override then the asset + # value is automatically returned instead + width = task_entity["attrib"][width_key] + height = task_entity["attrib"][height_key] + pixelAspect = task_entity["attrib"][pixelAspect_key] set_scene_resolution(width, height, pixelAspect) diff --git a/client/ayon_core/hosts/maya/plugins/publish/collect_instances.py b/client/ayon_core/hosts/maya/plugins/publish/collect_instances.py index 0b29851db0..03412f3301 100644 --- a/client/ayon_core/hosts/maya/plugins/publish/collect_instances.py +++ b/client/ayon_core/hosts/maya/plugins/publish/collect_instances.py @@ -3,6 +3,8 @@ import pyblish.api from ayon_core.hosts.maya.api.lib import get_all_children +from ayon_api import get_task_by_name + class CollectNewInstances(pyblish.api.InstancePlugin): """Gather members for instances and pre-defined attribute @@ -91,6 +93,13 @@ def process(self, instance): instance.data["frameEnd"] + instance.data["handleEnd"] ) + project_name = instance.context.data["projectName"] + asset_entity = instance.context.data["assetEntity"] + task_name = instance.data["task"] + task_entity = get_task_by_name( + project_name, asset_entity["_id"], task_name) + instance.data["taskEntity"] = task_entity + def get_all_parents(self, nodes): """Get all parents by using string operations (optimization) diff --git a/client/ayon_core/hosts/maya/plugins/publish/validate_frame_range.py b/client/ayon_core/hosts/maya/plugins/publish/validate_frame_range.py index d5f99e5563..3245aca1ed 100644 --- a/client/ayon_core/hosts/maya/plugins/publish/validate_frame_range.py +++ b/client/ayon_core/hosts/maya/plugins/publish/validate_frame_range.py @@ -1,3 +1,6 @@ + +import dataclasses + import pyblish.api from maya import cmds @@ -53,12 +56,24 @@ def process(self, instance): ) return - frame_start_handle = int(context.data.get("frameStartHandle")) - frame_end_handle = int(context.data.get("frameEndHandle")) - handle_start = int(context.data.get("handleStart")) - handle_end = int(context.data.get("handleEnd")) - frame_start = int(context.data.get("frameStart")) - frame_end = int(context.data.get("frameEnd")) + # Get frame information from task entity + # NOTE: If there is no task override then the asset + # value is automatically returned instead + frames = get_instance_task_frame_range(instance) + frame_start_handle = frames.frame_start_handle + frame_end_handle = frames.frame_end_handle + handle_start = frames.handle_start + handle_end = frames.handle_end + frame_start = frames.frame_start + frame_end = frames.frame_end + + # Get frame information from asset context + # frame_start_handle = int(context.data.get("frameStartHandle")) + # frame_end_handle = int(context.data.get("frameEndHandle")) + # handle_start = int(context.data.get("handleStart")) + # handle_end = int(context.data.get("handleEnd")) + # frame_start = int(context.data.get("frameStart")) + # frame_end = int(context.data.get("frameEnd")) inst_start = int(instance.data.get("frameStartHandle")) inst_end = int(instance.data.get("frameEndHandle")) @@ -130,12 +145,24 @@ def repair(cls, instance): node = instance.data["name"] context = instance.context - frame_start_handle = int(context.data.get("frameStartHandle")) - frame_end_handle = int(context.data.get("frameEndHandle")) - handle_start = int(context.data.get("handleStart")) - handle_end = int(context.data.get("handleEnd")) - frame_start = int(context.data.get("frameStart")) - frame_end = int(context.data.get("frameEnd")) + # Get frame information from task entity + # NOTE: If there is no task override then the asset + # value is automatically returned instead + frames = get_instance_task_frame_range(instance) + frame_start_handle = frames.frame_start_handle + frame_end_handle = frames.frame_end_handle + handle_start = frames.handle_start + handle_end = frames.handle_end + frame_start = frames.frame_start + frame_end = frames.frame_end + + # Get frame information from asset context + # frame_start_handle = int(context.data.get("frameStartHandle")) + # frame_end_handle = int(context.data.get("frameEndHandle")) + # handle_start = int(context.data.get("handleStart")) + # handle_end = int(context.data.get("handleEnd")) + # frame_start = int(context.data.get("frameStart")) + # frame_end = int(context.data.get("frameEnd")) # Start if cmds.attributeQuery("handleStart", node=node, exists=True): @@ -204,3 +231,38 @@ def _set_attr_in_layer(cls, node_attr, layer, value): value=value )) cmds.setAttr(node_attr, value) + + +def get_instance_task_frame_range(instance): + # Get frame information from task entity + # NOTE: If there is no task override then the asset + # value is automatically returned instead + attrib = instance.data["taskEntity"]["attrib"] + return FrameRange( + frame_start=attrib["frameStart"], + frame_end=attrib["frameEnd"], + handle_start=attrib["handleStart"], + handle_end=attrib["handleEnd"]) + + +@dataclasses.dataclass +class FrameRange: + """Frame range with handles. + + The frame range excludes the handles - and thus the handles are outside + of the frame range. To get the inclusive start and end frame use + `frame_start_handle` and `frame_end_handle`. + + """ + frame_start: int + frame_end: int + handle_start: int + handle_end: int + + @property + def frame_start_handle(self) -> int: + return self.frame_start - self.handle_start + + @property + def frame_end_handle(self) -> int: + return self.frame_end + self.handle_end \ No newline at end of file diff --git a/client/ayon_core/hosts/maya/plugins/publish/validate_resolution.py b/client/ayon_core/hosts/maya/plugins/publish/validate_resolution.py index ff552f566d..32064b9c2c 100644 --- a/client/ayon_core/hosts/maya/plugins/publish/validate_resolution.py +++ b/client/ayon_core/hosts/maya/plugins/publish/validate_resolution.py @@ -84,9 +84,13 @@ def get_invalid_resolution(cls, instance): @classmethod def get_db_resolution(cls, instance): + task_doc = instance.data["taskEntity"] asset_doc = instance.data["assetEntity"] project_doc = instance.context.data["projectEntity"] - for data in [asset_doc["data"], project_doc["data"]]: + for data in [ + task_doc["attrib"], + asset_doc["data"], + project_doc["data"]]: if ( "resolutionWidth" in data and "resolutionHeight" in data and