From 32873bdc22ce69e01de9ec15c629c5e8af43cfe5 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 3 Jul 2023 19:30:08 +0800 Subject: [PATCH 1/3] add functions for filtering in dailog in custom attr maxscript --- openpype/hosts/max/api/plugin.py | 43 ++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/max/api/plugin.py b/openpype/hosts/max/api/plugin.py index 14b0653f40..cb3a3b9e8d 100644 --- a/openpype/hosts/max/api/plugin.py +++ b/openpype/hosts/max/api/plugin.py @@ -15,6 +15,7 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" parameters main rollout:OPparams ( all_handles type:#maxObjectTab tabSize:0 tabSizeVariable:on + sel_list type:#stringTab tabSize:0 tabSizeVariable:on ) rollout OPparams "OP Parameters" @@ -30,11 +31,41 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" handle_name = obj_name + "<" + handle as string + ">" return handle_name ) + fn nodes_to_add node = + ( + sceneObjs = #() + n = node as string + for obj in Objects do + ( + tmp_obj = obj as string + append sceneObjs tmp_obj + ) + if sel_list != undefined do + ( + for obj in sel_list do + ( + idx = findItem sceneObjs obj + if idx do + ( + deleteItem sceneObjs idx + ) + ) + ) + idx = findItem sceneObjs n + if idx then return true else false + ) + + fn nodes_to_rmv node = + ( + n = node as string + idx = findItem sel_list n + if idx then return true else false + ) on button_add pressed do ( current_selection = selectByName title:"Select Objects to add to - the Container" buttontext:"Add" + the Container" buttontext:"Add" filter:nodes_to_add if current_selection == undefined then return False temp_arr = #() i_node_arr = #() @@ -46,8 +77,10 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" if idx do ( continue ) + name = c as string append temp_arr handle_name append i_node_arr node_ref + append sel_list name ) all_handles = join i_node_arr all_handles list_node.items = join temp_arr list_node.items @@ -56,7 +89,7 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" on button_del pressed do ( current_selection = selectByName title:"Select Objects to remove - from the Container" buttontext:"Remove" + from the Container" buttontext:"Remove" filter: nodes_to_rmv if current_selection == undefined then return False temp_arr = #() i_node_arr = #() @@ -67,6 +100,7 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" ( node_ref = NodeTransformMonitor node:c as string handle_name = node_to_name c + n = c as string tmp_all_handles = #() for i in all_handles do ( @@ -84,6 +118,11 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" ( new_temp_arr = DeleteItem list_node.items idx ) + idx = finditem sel_list n + if idx do + ( + sel_list = DeleteItem sel_list idx + ) ) all_handles = join i_node_arr new_i_node_arr list_node.items = join temp_arr new_temp_arr From 4a3c9ce4b665fda0081950f3be742afb01fc3218 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 5 Jul 2023 19:18:03 +0800 Subject: [PATCH 2/3] filter the container --- openpype/hosts/max/api/plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openpype/hosts/max/api/plugin.py b/openpype/hosts/max/api/plugin.py index cb3a3b9e8d..01ffc3ab27 100644 --- a/openpype/hosts/max/api/plugin.py +++ b/openpype/hosts/max/api/plugin.py @@ -34,6 +34,7 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" fn nodes_to_add node = ( sceneObjs = #() + if classOf node == Container do return false n = node as string for obj in Objects do ( @@ -53,6 +54,7 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" ) idx = findItem sceneObjs n if idx then return true else false + if classOf node == Container do return false ) fn nodes_to_rmv node = From d78d1e0c25b8fe74121831b320ac5a20ff358811 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 6 Jul 2023 16:31:56 +0800 Subject: [PATCH 3/3] remove redundency line --- openpype/hosts/max/api/plugin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/hosts/max/api/plugin.py b/openpype/hosts/max/api/plugin.py index 01ffc3ab27..d8db716e6d 100644 --- a/openpype/hosts/max/api/plugin.py +++ b/openpype/hosts/max/api/plugin.py @@ -54,7 +54,6 @@ MS_CUSTOM_ATTRIB = """attributes "openPypeData" ) idx = findItem sceneObjs n if idx then return true else false - if classOf node == Container do return false ) fn nodes_to_rmv node =