From a6004505af963122ba0eade8bfd896c761bf767b Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 15 Feb 2024 18:43:57 +0800 Subject: [PATCH 1/4] rename container to container node --- client/ayon_core/hosts/max/api/pipeline.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ayon_core/hosts/max/api/pipeline.py b/client/ayon_core/hosts/max/api/pipeline.py index 106c29fd26..98cb95eb9a 100644 --- a/client/ayon_core/hosts/max/api/pipeline.py +++ b/client/ayon_core/hosts/max/api/pipeline.py @@ -244,18 +244,18 @@ def get_previous_loaded_object(container: str): return node_list -def remove_container_data(container: str): +def remove_container_data(container_node: str): """Function to remove container data after updating, switching or deleting it. Args: - container (str): container + container_node (str): container node """ - if container.modifiers[0].name == "OP Data": + if container_node.modifiers[0].name == "OP Data": all_set_members_names = [ member.node for member - in container.modifiers[0].openPypeData.all_handles] + in container_node.modifiers[0].openPypeData.all_handles] for current_set_member in all_set_members_names: rt.Delete(current_set_member) - rt.deleteModifier(container, container.modifiers[0]) + rt.deleteModifier(container_node, container_node.modifiers[0]) - rt.Delete(container) + rt.Delete(container_node) From 59a3d87297aca1c7d564d1641ff2458e7390ca43 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 21 Feb 2024 18:48:39 +0800 Subject: [PATCH 2/4] make sure all the objects clean up when removing items with different alembic imports --- client/ayon_core/hosts/max/api/pipeline.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/ayon_core/hosts/max/api/pipeline.py b/client/ayon_core/hosts/max/api/pipeline.py index 98cb95eb9a..68e8a3a020 100644 --- a/client/ayon_core/hosts/max/api/pipeline.py +++ b/client/ayon_core/hosts/max/api/pipeline.py @@ -254,7 +254,12 @@ def remove_container_data(container_node: str): all_set_members_names = [ member.node for member in container_node.modifiers[0].openPypeData.all_handles] + # clean up the children of alembic dummy objects for current_set_member in all_set_members_names: + shape_list = [members for members in current_set_member.Children + if rt.ClassOf(members) == rt.AlembicObject] + if shape_list: + rt.Delete(shape_list) rt.Delete(current_set_member) rt.deleteModifier(container_node, container_node.modifiers[0]) From 6b18915e9ff63cdb1215cc65650cdcec7c50f284 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 22 Feb 2024 17:11:48 +0800 Subject: [PATCH 3/4] update loader scripts --- client/ayon_core/hosts/max/api/pipeline.py | 5 +++-- .../ayon_core/hosts/max/plugins/load/load_camera_fbx.py | 7 ++++--- client/ayon_core/hosts/max/plugins/load/load_max_scene.py | 6 +++--- client/ayon_core/hosts/max/plugins/load/load_model.py | 7 ++++--- client/ayon_core/hosts/max/plugins/load/load_model_fbx.py | 6 +++--- client/ayon_core/hosts/max/plugins/load/load_model_obj.py | 6 +++--- client/ayon_core/hosts/max/plugins/load/load_model_usd.py | 6 ++++-- .../ayon_core/hosts/max/plugins/load/load_pointcache.py | 7 ++++--- .../hosts/max/plugins/load/load_pointcache_ornatrix.py | 6 ++++-- .../ayon_core/hosts/max/plugins/load/load_pointcloud.py | 6 +++--- .../hosts/max/plugins/load/load_redshift_proxy.py | 8 ++++---- client/ayon_core/hosts/max/plugins/load/load_tycache.py | 6 +++--- 12 files changed, 42 insertions(+), 34 deletions(-) diff --git a/client/ayon_core/hosts/max/api/pipeline.py b/client/ayon_core/hosts/max/api/pipeline.py index 13b7f867f2..b7cec7e0ca 100644 --- a/client/ayon_core/hosts/max/api/pipeline.py +++ b/client/ayon_core/hosts/max/api/pipeline.py @@ -260,8 +260,9 @@ def remove_container_data(container_node: str): # clean up the children of alembic dummy objects for current_set_member in all_set_members_names: shape_list = [members for members in current_set_member.Children - if rt.ClassOf(members) == rt.AlembicObject] - if shape_list: + if rt.ClassOf(members) == rt.AlembicObject + or rt.isValidNode(members)] + if shape_list: # noqa rt.Delete(shape_list) rt.Delete(current_set_member) rt.deleteModifier(container_node, container_node.modifiers[0]) diff --git a/client/ayon_core/hosts/max/plugins/load/load_camera_fbx.py b/client/ayon_core/hosts/max/plugins/load/load_camera_fbx.py index 34b120c179..8387d7a837 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_camera_fbx.py +++ b/client/ayon_core/hosts/max/plugins/load/load_camera_fbx.py @@ -1,6 +1,6 @@ import os -from ayon_core.hosts.max.api import lib, maintained_selection +from ayon_core.hosts.max.api import lib from ayon_core.hosts.max.api.lib import ( unique_namespace, get_namespace, @@ -9,7 +9,8 @@ from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.pipeline import get_representation_path, load @@ -96,4 +97,4 @@ def remove(self, container): from pymxs import runtime as rt node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_max_scene.py b/client/ayon_core/hosts/max/plugins/load/load_max_scene.py index 7267d7a59e..ead77cd2f2 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_max_scene.py +++ b/client/ayon_core/hosts/max/plugins/load/load_max_scene.py @@ -8,7 +8,8 @@ ) from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.pipeline import get_representation_path, load @@ -93,6 +94,5 @@ def switch(self, container, representation): def remove(self, container): from pymxs import runtime as rt - node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_model.py b/client/ayon_core/hosts/max/plugins/load/load_model.py index 796e1b80ad..cf35e107c2 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_model.py +++ b/client/ayon_core/hosts/max/plugins/load/load_model.py @@ -2,7 +2,8 @@ from ayon_core.pipeline import load, get_representation_path from ayon_core.hosts.max.api.pipeline import ( containerise, - get_previous_loaded_object + get_previous_loaded_object, + remove_container_data ) from ayon_core.hosts.max.api import lib from ayon_core.hosts.max.api.lib import ( @@ -97,9 +98,9 @@ def switch(self, container, representation): def remove(self, container): from pymxs import runtime as rt - node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) + @staticmethod def get_container_children(parent, type_name): diff --git a/client/ayon_core/hosts/max/plugins/load/load_model_fbx.py b/client/ayon_core/hosts/max/plugins/load/load_model_fbx.py index 827cf63b39..c0bacca33a 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_model_fbx.py +++ b/client/ayon_core/hosts/max/plugins/load/load_model_fbx.py @@ -2,7 +2,8 @@ from ayon_core.pipeline import load, get_representation_path from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.hosts.max.api import lib from ayon_core.hosts.max.api.lib import ( @@ -92,6 +93,5 @@ def switch(self, container, representation): def remove(self, container): from pymxs import runtime as rt - node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_model_obj.py b/client/ayon_core/hosts/max/plugins/load/load_model_obj.py index 22d3d4b58a..1023b67f0c 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_model_obj.py +++ b/client/ayon_core/hosts/max/plugins/load/load_model_obj.py @@ -11,7 +11,8 @@ from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.pipeline import get_representation_path, load @@ -84,6 +85,5 @@ def switch(self, container, representation): def remove(self, container): from pymxs import runtime as rt - node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_model_usd.py b/client/ayon_core/hosts/max/plugins/load/load_model_usd.py index 8d42219217..0ec6e5e8e7 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_model_usd.py +++ b/client/ayon_core/hosts/max/plugins/load/load_model_usd.py @@ -13,7 +13,8 @@ from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.pipeline import get_representation_path, load @@ -113,5 +114,6 @@ def switch(self, container, representation): self.update(container, representation) def remove(self, container): + from pymxs import runtime as rt node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_pointcache.py b/client/ayon_core/hosts/max/plugins/load/load_pointcache.py index a92fa66757..e9cde4c654 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_pointcache.py +++ b/client/ayon_core/hosts/max/plugins/load/load_pointcache.py @@ -10,7 +10,8 @@ from ayon_core.hosts.max.api.lib import unique_namespace from ayon_core.hosts.max.api.pipeline import ( containerise, - get_previous_loaded_object + get_previous_loaded_object, + remove_container_data ) @@ -103,9 +104,9 @@ def switch(self, container, representation): def remove(self, container): from pymxs import runtime as rt - node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) + @staticmethod def get_container_children(parent, type_name): diff --git a/client/ayon_core/hosts/max/plugins/load/load_pointcache_ornatrix.py b/client/ayon_core/hosts/max/plugins/load/load_pointcache_ornatrix.py index 27b2e271d2..338cbfafb9 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_pointcache_ornatrix.py +++ b/client/ayon_core/hosts/max/plugins/load/load_pointcache_ornatrix.py @@ -4,7 +4,8 @@ from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.hosts.max.api.lib import ( @@ -104,5 +105,6 @@ def switch(self, container, representation): self.update(container, representation) def remove(self, container): + from pymxs import runtime as rt node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_pointcloud.py b/client/ayon_core/hosts/max/plugins/load/load_pointcloud.py index 45e3da5621..7f4fba50b3 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_pointcloud.py +++ b/client/ayon_core/hosts/max/plugins/load/load_pointcloud.py @@ -8,7 +8,8 @@ from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.pipeline import get_representation_path, load @@ -63,6 +64,5 @@ def switch(self, container, representation): def remove(self, container): """remove the container""" from pymxs import runtime as rt - node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_redshift_proxy.py b/client/ayon_core/hosts/max/plugins/load/load_redshift_proxy.py index 3f73210c24..5f2f5ec1ad 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_redshift_proxy.py +++ b/client/ayon_core/hosts/max/plugins/load/load_redshift_proxy.py @@ -9,7 +9,8 @@ from ayon_core.hosts.max.api.pipeline import ( containerise, update_custom_attribute_data, - get_previous_loaded_object + get_previous_loaded_object, + remove_container_data ) from ayon_core.hosts.max.api import lib from ayon_core.hosts.max.api.lib import ( @@ -72,6 +73,5 @@ def switch(self, container, representation): def remove(self, container): from pymxs import runtime as rt - - node = rt.getNodeByName(container["instance_node"]) - rt.delete(node) + node = rt.GetNodeByName(container["instance_node"]) + remove_container_data(node) diff --git a/client/ayon_core/hosts/max/plugins/load/load_tycache.py b/client/ayon_core/hosts/max/plugins/load/load_tycache.py index 48fb5c447a..7ae1aea72c 100644 --- a/client/ayon_core/hosts/max/plugins/load/load_tycache.py +++ b/client/ayon_core/hosts/max/plugins/load/load_tycache.py @@ -7,7 +7,8 @@ from ayon_core.hosts.max.api.pipeline import ( containerise, get_previous_loaded_object, - update_custom_attribute_data + update_custom_attribute_data, + remove_container_data ) from ayon_core.pipeline import get_representation_path, load @@ -59,6 +60,5 @@ def switch(self, container, representation): def remove(self, container): """remove the container""" from pymxs import runtime as rt - node = rt.GetNodeByName(container["instance_node"]) - rt.Delete(node) + remove_container_data(node) From e00a185469968cd270c294dc598869ecf30c0cfc Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 22 Feb 2024 17:33:46 +0800 Subject: [PATCH 4/4] make sure viewport gets refreshed after removing items in scene inventory --- client/ayon_core/hosts/max/api/pipeline.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_core/hosts/max/api/pipeline.py b/client/ayon_core/hosts/max/api/pipeline.py index b7cec7e0ca..1486f7218d 100644 --- a/client/ayon_core/hosts/max/api/pipeline.py +++ b/client/ayon_core/hosts/max/api/pipeline.py @@ -268,3 +268,4 @@ def remove_container_data(container_node: str): rt.deleteModifier(container_node, container_node.modifiers[0]) rt.Delete(container_node) + rt.redrawViews()