From 9b4c04c49316b3668bdaecf294698a9cfe778fb7 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Mon, 1 Apr 2024 14:12:55 +0200 Subject: [PATCH 1/6] use frame range from task attributes --- client/ayon_core/hosts/maya/api/lib.py | 27 ++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/lib.py b/client/ayon_core/hosts/maya/api/lib.py index b18d3a0c33..5144621014 100644 --- a/client/ayon_core/hosts/maya/api/lib.py +++ b/client/ayon_core/hosts/maya/api/lib.py @@ -2525,7 +2525,7 @@ def get_fps_for_current_context(): def get_frame_range(include_animation_range=False): - """Get the current folder frame range and handles. + """Get the current task frame range and handles. Args: include_animation_range (bool, optional): Whether to include @@ -2533,25 +2533,31 @@ def get_frame_range(include_animation_range=False): range of the timeline. It is excluded by default. Returns: - dict: Folder's expected frame range values. + dict: Task's expected frame range values. """ # Set frame start/end project_name = get_current_project_name() folder_path = get_current_folder_path() - folder_entity = ayon_api.get_folder_by_path(project_name, folder_path) - folder_attributes = folder_entity["attrib"] + task_name = get_current_task_name() - frame_start = folder_attributes.get("frameStart") - frame_end = folder_attributes.get("frameEnd") + folder_entity = ayon_api.get_folder_by_path(project_name, folder_path) + task_entity = ayon_api.get_task_by_name( + project_name, folder_entity["id"], task_name + ) + + task_attributes = task_entity["attrib"] + + frame_start = task_attributes.get("frameStart") + frame_end = task_attributes.get("frameEnd") if frame_start is None or frame_end is None: cmds.warning("No edit information found for '{}'".format(folder_path)) return - handle_start = folder_attributes.get("handleStart") or 0 - handle_end = folder_attributes.get("handleEnd") or 0 + handle_start = task_attributes.get("handleStart") or 0 + handle_end = task_attributes.get("handleEnd") or 0 frame_range = { "frameStart": frame_start, @@ -2565,11 +2571,8 @@ def get_frame_range(include_animation_range=False): # Some usages of this function use the full dictionary to define # instance attributes for which we want to exclude the animation # keys. That is why these are excluded by default. - task_name = get_current_task_name() + settings = get_project_settings(project_name) - task_entity = ayon_api.get_task_by_name( - project_name, folder_entity["id"], task_name - ) task_type = None if task_entity: task_type = task_entity["taskType"] From b110afd12eda2700cf24381cdde79096e3337f76 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 2 Apr 2024 11:47:16 +0200 Subject: [PATCH 2/6] BigRoy's comments - Imporve get_frame_Range's logic --- client/ayon_core/hosts/maya/api/lib.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/hosts/maya/api/lib.py b/client/ayon_core/hosts/maya/api/lib.py index 5144621014..9b4c5e2b41 100644 --- a/client/ayon_core/hosts/maya/api/lib.py +++ b/client/ayon_core/hosts/maya/api/lib.py @@ -2542,7 +2542,10 @@ def get_frame_range(include_animation_range=False): folder_path = get_current_folder_path() task_name = get_current_task_name() - folder_entity = ayon_api.get_folder_by_path(project_name, folder_path) + folder_entity = ayon_api.get_folder_by_path( + project_name, + folder_path, + fields={"id"}) task_entity = ayon_api.get_task_by_name( project_name, folder_entity["id"], task_name ) @@ -2573,9 +2576,8 @@ def get_frame_range(include_animation_range=False): # keys. That is why these are excluded by default. settings = get_project_settings(project_name) - task_type = None - if task_entity: - task_type = task_entity["taskType"] + + task_type = task_entity["taskType"] include_handles_settings = settings["maya"]["include_handles"] From d820b96295a185b0786a8a3006ffbcaa121e909c Mon Sep 17 00:00:00 2001 From: ChunYou Date: Tue, 2 Apr 2024 14:05:18 +0100 Subject: [PATCH 3/6] Track m handles then object name --- client/ayon_core/hosts/max/api/pipeline.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/ayon_core/hosts/max/api/pipeline.py b/client/ayon_core/hosts/max/api/pipeline.py index 4b1dcc25d3..8a4da711ee 100644 --- a/client/ayon_core/hosts/max/api/pipeline.py +++ b/client/ayon_core/hosts/max/api/pipeline.py @@ -240,10 +240,9 @@ def get_previous_loaded_object(container: str): node_list(list): list of nodes which are previously loaded """ node_list = [] - sel_list = rt.getProperty(container.modifiers[0].openPypeData, "sel_list") - for obj in rt.Objects: - if str(obj) in sel_list: - node_list.append(obj) + node_transform_monitor_list = rt.getProperty(container.modifiers[0].openPypeData, "all_handles") + for node_transform_monitor in node_transform_monitor_list: + node_list.append(node_transform_monitor.node) return node_list From f6cbe023b71ecaba8ab6b2c7cceb46c072d21d04 Mon Sep 17 00:00:00 2001 From: r42-chun <73248638+r42-chun@users.noreply.github.com> Date: Wed, 3 Apr 2024 04:10:47 +0100 Subject: [PATCH 4/6] Adjust styling line length Co-authored-by: Roy Nieterau --- client/ayon_core/hosts/max/api/pipeline.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/hosts/max/api/pipeline.py b/client/ayon_core/hosts/max/api/pipeline.py index 8a4da711ee..675f36c24f 100644 --- a/client/ayon_core/hosts/max/api/pipeline.py +++ b/client/ayon_core/hosts/max/api/pipeline.py @@ -240,7 +240,8 @@ def get_previous_loaded_object(container: str): node_list(list): list of nodes which are previously loaded """ node_list = [] - node_transform_monitor_list = rt.getProperty(container.modifiers[0].openPypeData, "all_handles") + node_transform_monitor_list = rt.getProperty( + container.modifiers[0].openPypeData, "all_handles") for node_transform_monitor in node_transform_monitor_list: node_list.append(node_transform_monitor.node) return node_list From e561481725743f594ede5c46852d24cb69a03157 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 3 Apr 2024 12:44:02 +0200 Subject: [PATCH 5/6] remove empty lines --- client/ayon_core/settings/lib.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/client/ayon_core/settings/lib.py b/client/ayon_core/settings/lib.py index d72e4f357a..a77cdb8046 100644 --- a/client/ayon_core/settings/lib.py +++ b/client/ayon_core/settings/lib.py @@ -209,6 +209,3 @@ def get_current_project_settings(): "Missing context project in environemt variable `AYON_PROJECT_NAME`." ) return get_project_settings(project_name) - - - From 87cfc92b61e7409f9403f19a8ee00bad3799d42e Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 3 Apr 2024 12:44:08 +0200 Subject: [PATCH 6/6] fix typo --- client/ayon_core/settings/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/settings/lib.py b/client/ayon_core/settings/lib.py index a77cdb8046..3929818d31 100644 --- a/client/ayon_core/settings/lib.py +++ b/client/ayon_core/settings/lib.py @@ -201,7 +201,7 @@ def get_current_project_settings(): Project name should be stored in environment variable `AYON_PROJECT_NAME`. This function should be used only in host context where environment variable must be set and should not happen that any part of process will - change the value of the enviornment variable. + change the value of the environment variable. """ project_name = os.environ.get("AYON_PROJECT_NAME") if not project_name: