From 70bab9fdb8e673350e76e2e7fc18e967b86c6e8e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 13 Sep 2023 21:59:57 +0800 Subject: [PATCH] fixing the issue of duplciated contents during switching assets --- openpype/hosts/max/plugins/load/load_camera_fbx.py | 5 ++++- openpype/hosts/max/plugins/load/load_model_fbx.py | 4 +++- openpype/hosts/max/plugins/load/load_model_obj.py | 4 +++- openpype/hosts/max/plugins/load/load_model_usd.py | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/max/plugins/load/load_camera_fbx.py b/openpype/hosts/max/plugins/load/load_camera_fbx.py index 156e8dcaf6..5e4623fe4c 100644 --- a/openpype/hosts/max/plugins/load/load_camera_fbx.py +++ b/openpype/hosts/max/plugins/load/load_camera_fbx.py @@ -73,7 +73,10 @@ class FbxLoader(load.LoaderPlugin): rt.FBXImporterSetParam("Preserveinstances", True) rt.ImportFile( path, rt.name("noPrompt"), using=rt.FBXIMP) - current_fbx_objects = rt.GetCurrentSelection() + current_fbx_objects = [sel for sel in rt.GetCurrentSelection() + if sel != rt.Container + and sel.name == node_name] + update_custom_attribute_data(node, current_fbx_objects) for fbx_object in current_fbx_objects: fbx_object.name = f"{namespace}:{fbx_object.name}" diff --git a/openpype/hosts/max/plugins/load/load_model_fbx.py b/openpype/hosts/max/plugins/load/load_model_fbx.py index bea4d28fb7..9542eaa74e 100644 --- a/openpype/hosts/max/plugins/load/load_model_fbx.py +++ b/openpype/hosts/max/plugins/load/load_model_fbx.py @@ -56,7 +56,9 @@ class FbxModelLoader(load.LoaderPlugin): node_list = get_previous_loaded_object(node) rt.Select(node_list) - prev_fbx_objects = rt.GetCurrentSelection() + prev_fbx_objects = [sel for sel in rt.GetCurrentSelection() + if sel != rt.Container + and sel.name == node_name] transform_data = object_transform_set(prev_fbx_objects) for prev_fbx_obj in prev_fbx_objects: if rt.isValidNode(prev_fbx_obj): diff --git a/openpype/hosts/max/plugins/load/load_model_obj.py b/openpype/hosts/max/plugins/load/load_model_obj.py index ca970fb9d7..38ba5e3e8f 100644 --- a/openpype/hosts/max/plugins/load/load_model_obj.py +++ b/openpype/hosts/max/plugins/load/load_model_obj.py @@ -55,7 +55,9 @@ class ObjLoader(load.LoaderPlugin): namespace, _ = get_namespace(node_name) node_list = get_previous_loaded_object(node) rt.Select(node_list) - previous_objects = rt.GetCurrentSelection() + previous_objects = [sel for sel in rt.GetCurrentSelection() + if sel != rt.Container + and sel.name == node_name] transform_data = object_transform_set(previous_objects) for prev_obj in previous_objects: if rt.isValidNode(prev_obj): diff --git a/openpype/hosts/max/plugins/load/load_model_usd.py b/openpype/hosts/max/plugins/load/load_model_usd.py index 6476f65a04..cabcdaa6b5 100644 --- a/openpype/hosts/max/plugins/load/load_model_usd.py +++ b/openpype/hosts/max/plugins/load/load_model_usd.py @@ -71,7 +71,9 @@ class ModelUSDLoader(load.LoaderPlugin): namespace, name = get_namespace(node_name) node_list = get_previous_loaded_object(node) rt.Select(node_list) - prev_objects = rt.GetCurrentSelection() + prev_objects = [sel for sel in rt.GetCurrentSelection() + if sel != rt.Container + and sel.name == node_name] transform_data = object_transform_set(prev_objects) for n in prev_objects: rt.Delete(n)