From 627825381a3b914c2d7468231e83d6c862f5e214 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 21 Nov 2024 17:32:03 +0800 Subject: [PATCH 1/2] added the project name as being part of the container data for loading and updating assets --- client/ayon_max/api/pipeline.py | 1 + client/ayon_max/hooks/force_startup_script.py | 1 - client/ayon_max/plugins/load/load_camera_fbx.py | 3 ++- client/ayon_max/plugins/load/load_max_scene.py | 3 ++- client/ayon_max/plugins/load/load_model.py | 11 ++++++----- client/ayon_max/plugins/load/load_model_fbx.py | 6 ++++-- client/ayon_max/plugins/load/load_model_obj.py | 7 ++++--- client/ayon_max/plugins/load/load_model_usd.py | 5 +++-- client/ayon_max/plugins/load/load_pointcache.py | 9 +++++---- .../ayon_max/plugins/load/load_pointcache_ornatrix.py | 8 ++++---- client/ayon_max/plugins/load/load_pointcloud.py | 4 +++- client/ayon_max/plugins/load/load_redshift_proxy.py | 3 ++- client/ayon_max/plugins/load/load_tycache.py | 4 +++- 13 files changed, 39 insertions(+), 26 deletions(-) diff --git a/client/ayon_max/api/pipeline.py b/client/ayon_max/api/pipeline.py index 5f57ed0a79..9d56e0bf17 100644 --- a/client/ayon_max/api/pipeline.py +++ b/client/ayon_max/api/pipeline.py @@ -202,6 +202,7 @@ def containerise(name: str, nodes: list, context, "namespace": namespace or "", "loader": loader, "representation": context["representation"]["id"], + "project_name": context["project"]["name"] } container_name = f"{namespace}:{name}{suffix}" container = rt.container(name=container_name) diff --git a/client/ayon_max/hooks/force_startup_script.py b/client/ayon_max/hooks/force_startup_script.py index 1699ea300a..da3a34ce18 100644 --- a/client/ayon_max/hooks/force_startup_script.py +++ b/client/ayon_max/hooks/force_startup_script.py @@ -15,7 +15,6 @@ class ForceStartupScript(PreLaunchHook): Hook `GlobalHostDataHook` must be executed before this hook. """ app_groups = {"3dsmax", "adsk_3dsmax"} - order = 11 launch_types = {LaunchTypes.local} def execute(self): diff --git a/client/ayon_max/plugins/load/load_camera_fbx.py b/client/ayon_max/plugins/load/load_camera_fbx.py index 81ea15d52a..d6b55246ef 100644 --- a/client/ayon_max/plugins/load/load_camera_fbx.py +++ b/client/ayon_max/plugins/load/load_camera_fbx.py @@ -88,7 +88,8 @@ def update(self, container, context): update_custom_attribute_data(node, fbx_objects) lib.imprint(container["instance_node"], { - "representation": repre_entity["id"] + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): diff --git a/client/ayon_max/plugins/load/load_max_scene.py b/client/ayon_max/plugins/load/load_max_scene.py index 7fca69b193..02432d23b0 100644 --- a/client/ayon_max/plugins/load/load_max_scene.py +++ b/client/ayon_max/plugins/load/load_max_scene.py @@ -166,7 +166,8 @@ def update(self, container, context): update_custom_attribute_data(node, max_objects) lib.imprint(container["instance_node"], { - "representation": repre_entity["id"] + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): diff --git a/client/ayon_max/plugins/load/load_model.py b/client/ayon_max/plugins/load/load_model.py index 2a6bc45c18..94466174ab 100644 --- a/client/ayon_max/plugins/load/load_model.py +++ b/client/ayon_max/plugins/load/load_model.py @@ -74,7 +74,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node = rt.GetNodeByName(container["instance_node"]) node_list = [n for n in get_previous_loaded_object(node) if rt.ClassOf(n) == rt.AlembicContainer] @@ -89,10 +89,11 @@ def update(self, container, context): rt.Select(abc_con.Children) for abc_obj in abc_con.Children: abc_obj.source = path - lib.imprint( - container["instance_node"], - {"representation": repre_entity["id"]}, - ) + + lib.imprint(container["instance_node"], { + "representation": repre_entity["id"], + "project_name": context["project"]["name"] + }) def switch(self, container, context): self.update(container, context) diff --git a/client/ayon_max/plugins/load/load_model_fbx.py b/client/ayon_max/plugins/load/load_model_fbx.py index 2775e1b453..cc33cd3d04 100644 --- a/client/ayon_max/plugins/load/load_model_fbx.py +++ b/client/ayon_max/plugins/load/load_model_fbx.py @@ -51,7 +51,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node_name = container["instance_node"] node = rt.getNodeByName(node_name) if not node: @@ -85,8 +85,10 @@ def update(self, container, context): with maintained_selection(): rt.Select(node) update_custom_attribute_data(node, fbx_objects) + lib.imprint(container["instance_node"], { - "representation": repre_entity["id"] + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): diff --git a/client/ayon_max/plugins/load/load_model_obj.py b/client/ayon_max/plugins/load/load_model_obj.py index d38aadb5bc..ac151a14c8 100644 --- a/client/ayon_max/plugins/load/load_model_obj.py +++ b/client/ayon_max/plugins/load/load_model_obj.py @@ -50,7 +50,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node_name = container["instance_node"] node = rt.getNodeByName(node_name) namespace, _ = get_namespace(node_name) @@ -76,8 +76,9 @@ def update(self, container, context): with maintained_selection(): rt.Select(node) - lib.imprint(node_name, { - "representation": repre_entity["id"] + lib.imprint(container["instance_node"], { + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): diff --git a/client/ayon_max/plugins/load/load_model_usd.py b/client/ayon_max/plugins/load/load_model_usd.py index f4dd41d5db..e4e41c71b6 100644 --- a/client/ayon_max/plugins/load/load_model_usd.py +++ b/client/ayon_max/plugins/load/load_model_usd.py @@ -107,8 +107,9 @@ def update(self, container, context): with maintained_selection(): rt.Select(node) - lib.imprint(node_name, { - "representation": repre_entity["id"] + lib.imprint(container["instance_node"], { + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): diff --git a/client/ayon_max/plugins/load/load_pointcache.py b/client/ayon_max/plugins/load/load_pointcache.py index 87ea5c75bc..b2e2f842a9 100644 --- a/client/ayon_max/plugins/load/load_pointcache.py +++ b/client/ayon_max/plugins/load/load_pointcache.py @@ -98,10 +98,11 @@ def update(self, container, context): rt.Select(abc_con.Children) for abc_obj in abc_con.Children: abc_obj.source = path - lib.imprint( - container["instance_node"], - {"representation": repre_entity["id"]}, - ) + + lib.imprint(container["instance_node"], { + "representation": repre_entity["id"], + "project_name": context["project"]["name"] + }) def switch(self, container, context): self.update(container, context) diff --git a/client/ayon_max/plugins/load/load_pointcache_ornatrix.py b/client/ayon_max/plugins/load/load_pointcache_ornatrix.py index bc997951c1..71feffa6dd 100644 --- a/client/ayon_max/plugins/load/load_pointcache_ornatrix.py +++ b/client/ayon_max/plugins/load/load_pointcache_ornatrix.py @@ -97,10 +97,10 @@ def update(self, container, context): abc.pos = transform_data[ox_transform] or 0 abc.scale = transform_data[f"{abc}.scale"] or 0 update_custom_attribute_data(node, ox_abc_objects) - lib.imprint( - container["instance_node"], - {"representation": repre_entity["id"]}, - ) + lib.imprint(container["instance_node"], { + "representation": repre_entity["id"], + "project_name": context["project"]["name"] + }) def switch(self, container, context): self.update(container, context) diff --git a/client/ayon_max/plugins/load/load_pointcloud.py b/client/ayon_max/plugins/load/load_pointcloud.py index 0fb506d5bd..0525866091 100644 --- a/client/ayon_max/plugins/load/load_pointcloud.py +++ b/client/ayon_max/plugins/load/load_pointcloud.py @@ -55,8 +55,10 @@ def update(self, container, context): rt.Select(node_list) for prt in rt.Selection: prt.filename = path + lib.imprint(container["instance_node"], { - "representation": repre_entity["id"] + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): diff --git a/client/ayon_max/plugins/load/load_redshift_proxy.py b/client/ayon_max/plugins/load/load_redshift_proxy.py index 3fd84b7538..4a3cbb182e 100644 --- a/client/ayon_max/plugins/load/load_redshift_proxy.py +++ b/client/ayon_max/plugins/load/load_redshift_proxy.py @@ -66,7 +66,8 @@ def update(self, container, context): proxy.file = path lib.imprint(container["instance_node"], { - "representation": repre_entity["id"] + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): diff --git a/client/ayon_max/plugins/load/load_tycache.py b/client/ayon_max/plugins/load/load_tycache.py index 7fa2215273..0dbb813241 100644 --- a/client/ayon_max/plugins/load/load_tycache.py +++ b/client/ayon_max/plugins/load/load_tycache.py @@ -51,8 +51,10 @@ def update(self, container, context): with maintained_selection(): for tyc in node_list: tyc.filename = path + lib.imprint(container["instance_node"], { - "representation": repre_entity["id"] + "representation": repre_entity["id"], + "project_name": context["project"]["name"] }) def switch(self, container, context): From fe4de3f7ea98d233ae4fdc7e21f6e9f9cfbff371 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 21 Nov 2024 17:40:44 +0800 Subject: [PATCH 2/2] replace get_representation_path with os.path.normpath(self.filepath_from_context(context)) --- client/ayon_max/hooks/force_startup_script.py | 1 + client/ayon_max/plugins/load/load_camera_fbx.py | 4 ++-- client/ayon_max/plugins/load/load_max_scene.py | 4 ++-- client/ayon_max/plugins/load/load_model.py | 2 +- client/ayon_max/plugins/load/load_model_fbx.py | 2 +- client/ayon_max/plugins/load/load_model_obj.py | 2 +- client/ayon_max/plugins/load/load_model_usd.py | 4 ++-- client/ayon_max/plugins/load/load_pointcache.py | 4 ++-- client/ayon_max/plugins/load/load_pointcache_ornatrix.py | 4 ++-- client/ayon_max/plugins/load/load_pointcloud.py | 4 ++-- client/ayon_max/plugins/load/load_redshift_proxy.py | 7 ++----- client/ayon_max/plugins/load/load_tycache.py | 4 ++-- 12 files changed, 20 insertions(+), 22 deletions(-) diff --git a/client/ayon_max/hooks/force_startup_script.py b/client/ayon_max/hooks/force_startup_script.py index da3a34ce18..1699ea300a 100644 --- a/client/ayon_max/hooks/force_startup_script.py +++ b/client/ayon_max/hooks/force_startup_script.py @@ -15,6 +15,7 @@ class ForceStartupScript(PreLaunchHook): Hook `GlobalHostDataHook` must be executed before this hook. """ app_groups = {"3dsmax", "adsk_3dsmax"} + order = 11 launch_types = {LaunchTypes.local} def execute(self): diff --git a/client/ayon_max/plugins/load/load_camera_fbx.py b/client/ayon_max/plugins/load/load_camera_fbx.py index d6b55246ef..3a19b556f9 100644 --- a/client/ayon_max/plugins/load/load_camera_fbx.py +++ b/client/ayon_max/plugins/load/load_camera_fbx.py @@ -12,7 +12,7 @@ update_custom_attribute_data, remove_container_data ) -from ayon_core.pipeline import get_representation_path, load +from ayon_core.pipeline import load class FbxLoader(load.LoaderPlugin): @@ -55,7 +55,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node_name = container["instance_node"] node = rt.getNodeByName(node_name) namespace, _ = get_namespace(node_name) diff --git a/client/ayon_max/plugins/load/load_max_scene.py b/client/ayon_max/plugins/load/load_max_scene.py index 02432d23b0..30adf83a4e 100644 --- a/client/ayon_max/plugins/load/load_max_scene.py +++ b/client/ayon_max/plugins/load/load_max_scene.py @@ -13,7 +13,7 @@ update_custom_attribute_data, remove_container_data ) -from ayon_core.pipeline import get_representation_path, load +from ayon_core.pipeline import load class MaterialDupOptionsWindow(QtWidgets.QDialog): @@ -126,7 +126,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node_name = container["instance_node"] node = rt.getNodeByName(node_name) namespace, _ = get_namespace(node_name) diff --git a/client/ayon_max/plugins/load/load_model.py b/client/ayon_max/plugins/load/load_model.py index 94466174ab..3a3000cb8f 100644 --- a/client/ayon_max/plugins/load/load_model.py +++ b/client/ayon_max/plugins/load/load_model.py @@ -1,5 +1,5 @@ import os -from ayon_core.pipeline import load, get_representation_path +from ayon_core.pipeline import load from ayon_max.api.pipeline import ( containerise, get_previous_loaded_object, diff --git a/client/ayon_max/plugins/load/load_model_fbx.py b/client/ayon_max/plugins/load/load_model_fbx.py index cc33cd3d04..2c48ef516d 100644 --- a/client/ayon_max/plugins/load/load_model_fbx.py +++ b/client/ayon_max/plugins/load/load_model_fbx.py @@ -1,5 +1,5 @@ import os -from ayon_core.pipeline import load, get_representation_path +from ayon_core.pipeline import load from ayon_max.api.pipeline import ( containerise, get_previous_loaded_object, update_custom_attribute_data, diff --git a/client/ayon_max/plugins/load/load_model_obj.py b/client/ayon_max/plugins/load/load_model_obj.py index ac151a14c8..30c59e2014 100644 --- a/client/ayon_max/plugins/load/load_model_obj.py +++ b/client/ayon_max/plugins/load/load_model_obj.py @@ -13,7 +13,7 @@ update_custom_attribute_data, remove_container_data ) -from ayon_core.pipeline import get_representation_path, load +from ayon_core.pipeline import load class ObjLoader(load.LoaderPlugin): diff --git a/client/ayon_max/plugins/load/load_model_usd.py b/client/ayon_max/plugins/load/load_model_usd.py index e4e41c71b6..39330fcc3f 100644 --- a/client/ayon_max/plugins/load/load_model_usd.py +++ b/client/ayon_max/plugins/load/load_model_usd.py @@ -16,7 +16,7 @@ update_custom_attribute_data, remove_container_data ) -from ayon_core.pipeline import get_representation_path, load +from ayon_core.pipeline import load class ModelUSDLoader(load.LoaderPlugin): @@ -67,7 +67,7 @@ def load(self, context, name=None, namespace=None, data=None): def update(self, container, context): repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node_name = container["instance_node"] node = rt.GetNodeByName(node_name) namespace, name = get_namespace(node_name) diff --git a/client/ayon_max/plugins/load/load_pointcache.py b/client/ayon_max/plugins/load/load_pointcache.py index b2e2f842a9..57b47b239c 100644 --- a/client/ayon_max/plugins/load/load_pointcache.py +++ b/client/ayon_max/plugins/load/load_pointcache.py @@ -5,7 +5,7 @@ """ import os -from ayon_core.pipeline import load, get_representation_path +from ayon_core.pipeline import load from ayon_max.api import lib, maintained_selection from ayon_max.api.lib import unique_namespace, reset_frame_range from ayon_max.api.pipeline import ( @@ -83,7 +83,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node = rt.GetNodeByName(container["instance_node"]) abc_container = [n for n in get_previous_loaded_object(node) if rt.ClassOf(n) == rt.AlembicContainer] diff --git a/client/ayon_max/plugins/load/load_pointcache_ornatrix.py b/client/ayon_max/plugins/load/load_pointcache_ornatrix.py index 71feffa6dd..1238dc9ed3 100644 --- a/client/ayon_max/plugins/load/load_pointcache_ornatrix.py +++ b/client/ayon_max/plugins/load/load_pointcache_ornatrix.py @@ -1,5 +1,5 @@ import os -from ayon_core.pipeline import load, get_representation_path +from ayon_core.pipeline import load from ayon_core.pipeline.load import LoadError from ayon_max.api.pipeline import ( containerise, @@ -64,7 +64,7 @@ def load(self, context, name=None, namespace=None, data=None): def update(self, container, context): repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node_name = container["instance_node"] namespace, name = get_namespace(node_name) node = rt.getNodeByName(node_name) diff --git a/client/ayon_max/plugins/load/load_pointcloud.py b/client/ayon_max/plugins/load/load_pointcloud.py index 0525866091..e84961c37c 100644 --- a/client/ayon_max/plugins/load/load_pointcloud.py +++ b/client/ayon_max/plugins/load/load_pointcloud.py @@ -11,7 +11,7 @@ update_custom_attribute_data, remove_container_data ) -from ayon_core.pipeline import get_representation_path, load +from ayon_core.pipeline import load class PointCloudLoader(load.LoaderPlugin): @@ -46,7 +46,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node = rt.GetNodeByName(container["instance_node"]) node_list = get_previous_loaded_object(node) update_custom_attribute_data( diff --git a/client/ayon_max/plugins/load/load_redshift_proxy.py b/client/ayon_max/plugins/load/load_redshift_proxy.py index 4a3cbb182e..2dec4766ee 100644 --- a/client/ayon_max/plugins/load/load_redshift_proxy.py +++ b/client/ayon_max/plugins/load/load_redshift_proxy.py @@ -1,10 +1,7 @@ import os import clique -from ayon_core.pipeline import ( - load, - get_representation_path -) +from ayon_core.pipeline import load from ayon_core.pipeline.load import LoadError from ayon_max.api.pipeline import ( containerise, @@ -56,7 +53,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node = rt.getNodeByName(container["instance_node"]) node_list = get_previous_loaded_object(node) rt.Select(node_list) diff --git a/client/ayon_max/plugins/load/load_tycache.py b/client/ayon_max/plugins/load/load_tycache.py index 0dbb813241..bbb47948ad 100644 --- a/client/ayon_max/plugins/load/load_tycache.py +++ b/client/ayon_max/plugins/load/load_tycache.py @@ -10,7 +10,7 @@ update_custom_attribute_data, remove_container_data ) -from ayon_core.pipeline import get_representation_path, load +from ayon_core.pipeline import load class TyCacheLoader(load.LoaderPlugin): @@ -44,7 +44,7 @@ def update(self, container, context): from pymxs import runtime as rt repre_entity = context["representation"] - path = get_representation_path(repre_entity) + path = os.path.normpath(self.filepath_from_context(context)) node = rt.GetNodeByName(container["instance_node"]) node_list = get_previous_loaded_object(node) update_custom_attribute_data(node, node_list)