diff --git a/openpype/hosts/maya/api/lib.py b/openpype/hosts/maya/api/lib.py index bd26738040..f6fcab7e40 100644 --- a/openpype/hosts/maya/api/lib.py +++ b/openpype/hosts/maya/api/lib.py @@ -32,7 +32,12 @@ from openpype.pipeline import ( load_container, registered_host, ) -from openpype.pipeline.context_tools import get_current_project_asset +from openpype.pipeline.context_tools import ( + get_current_asset_name, + get_current_project_asset, + get_current_project_name, + get_current_task_name +) self = sys.modules[__name__] @@ -292,15 +297,20 @@ def collect_animation_data(fps=False): """ # get scene values as defaults - start = cmds.playbackOptions(query=True, animationStartTime=True) - end = cmds.playbackOptions(query=True, animationEndTime=True) + frame_start = cmds.playbackOptions(query=True, minTime=True) + frame_end = cmds.playbackOptions(query=True, maxTime=True) + handle_start = cmds.playbackOptions(query=True, animationStartTime=True) + handle_end = cmds.playbackOptions(query=True, animationEndTime=True) + + handle_start = frame_start - handle_start + handle_end = handle_end - frame_end # build attributes data = OrderedDict() - data["frameStart"] = start - data["frameEnd"] = end - data["handleStart"] = 0 - data["handleEnd"] = 0 + data["frameStart"] = frame_start + data["frameEnd"] = frame_end + data["handleStart"] = handle_start + data["handleEnd"] = handle_end data["step"] = 1.0 if fps: @@ -2134,9 +2144,13 @@ def get_frame_range(): """Get the current assets frame range and handles.""" # Set frame start/end - project_name = legacy_io.active_project() - asset_name = legacy_io.Session["AVALON_ASSET"] + project_name = get_current_project_name() + task_name = get_current_task_name() + asset_name = get_current_asset_name() asset = get_asset_by_name(project_name, asset_name) + settings = get_project_settings(project_name) + include_handles_settings = settings["maya"]["include_handles"] + current_task = asset.get("data").get("tasks").get(task_name) frame_start = asset["data"].get("frameStart") frame_end = asset["data"].get("frameEnd") @@ -2148,6 +2162,26 @@ def get_frame_range(): handle_start = asset["data"].get("handleStart") or 0 handle_end = asset["data"].get("handleEnd") or 0 + animation_start = frame_start + animation_end = frame_end + + include_handles = include_handles_settings["include_handles_default"] + for item in include_handles_settings["per_task_type"]: + if current_task["type"] in item["task_type"]: + include_handles = item["include_handles"] + break + if include_handles: + animation_start -= int(handle_start) + animation_end += int(handle_end) + + cmds.playbackOptions( + minTime=frame_start, + maxTime=frame_end, + animationStartTime=animation_start, + animationEndTime=animation_end + ) + cmds.currentTime(frame_start) + return { "frameStart": frame_start, "frameEnd": frame_end, @@ -2166,7 +2200,6 @@ def reset_frame_range(playback=True, render=True, fps=True): Defaults to True. fps (bool, Optional): Whether to set scene FPS. Defaults to True. """ - if fps: fps = convert_to_maya_fps( float(legacy_io.Session.get("AVALON_FPS", 25)) diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index a8689524db..201dda1c2d 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -1144,6 +1144,10 @@ } ] }, + "include_handles": { + "include_handles_default": false, + "per_task_type": [] + }, "templated_workfile_build": { "profiles": [] }, diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_maya.json b/openpype/settings/entities/schemas/projects_schema/schema_project_maya.json index 47dfb37024..ccc967a260 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_maya.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_maya.json @@ -151,6 +151,40 @@ } ] }, + { + "type": "dict", + "key": "include_handles", + "collapsible": true, + "label": "Include/Exclude Handles in default playback & render range", + "children": [ + { + "key": "include_handles_default", + "label": "Include handles by default", + "type": "boolean" + }, + { + "type": "list", + "key": "per_task_type", + "label": "Include/exclude handles by task type", + "use_label_wrap": true, + "object_type": { + "type": "dict", + "children": [ + { + "type": "task-types-enum", + "key": "task_type", + "label": "Task types" + }, + { + "type": "boolean", + "key": "include_handles", + "label": "Include handles" + } + ] + } + } + ] + }, { "type": "schema", "name": "schema_scriptsmenu" diff --git a/website/docs/admin_hosts_maya.md b/website/docs/admin_hosts_maya.md index 0dd86d6e7c..eea6456c76 100644 --- a/website/docs/admin_hosts_maya.md +++ b/website/docs/admin_hosts_maya.md @@ -200,6 +200,16 @@ Most settings to override in the viewport are self explanatory and can be found These options are set on the camera shape when publishing the review. They correspond to attributes on the Maya camera shape node. ![Extract Playblast Settings](assets/maya-admin_extract_playblast_settings_camera_options.png) +## Include/exclude handles by task type +You can include or exclude handles, globally or by task type. + +The "Include handles by default" defines whether by default handles are included. Additionally you can add a per task type override whether you want to include or exclude handles. + +For example, in this image you can see that handles are included by default in all task types, except for the 'Lighting' task, where the toggle is disabled. +![Include/exclude handles](assets/maya-admin_exclude_handles.png) + +And here you can see that the handles are disabled by default, except in 'Animation' task where it's enabled. +![Custom menu definition](assets/maya-admin_include_handles.png) ## Custom Menu diff --git a/website/docs/assets/maya-admin_exclude_handles.png b/website/docs/assets/maya-admin_exclude_handles.png new file mode 100644 index 0000000000..9a50f2c287 Binary files /dev/null and b/website/docs/assets/maya-admin_exclude_handles.png differ diff --git a/website/docs/assets/maya-admin_include_handles.png b/website/docs/assets/maya-admin_include_handles.png new file mode 100644 index 0000000000..88d2270ddc Binary files /dev/null and b/website/docs/assets/maya-admin_include_handles.png differ