fix the subset name not changing acoordingly after the subset changes

This commit is contained in:
Kayla Man 2023-11-14 16:13:06 +08:00
parent b17cff302e
commit 2053c4f4c9
2 changed files with 17 additions and 5 deletions

View file

@ -42,6 +42,7 @@ def imprint(node_name: str, data: dict) -> bool:
rt.SetUserProp(node, k, f"{JSON_PREFIX}{json.dumps(v)}")
else:
rt.SetUserProp(node, k, v)
print(k)
return True
@ -359,8 +360,6 @@ def reset_colorspace():
colorspace_mgr.Mode = rt.Name("OCIO_Custom")
colorspace_mgr.OCIOConfigPath = ocio_config_path
colorspace_mgr.OCIOConfigPath = ocio_config_path
def check_colorspace():
parent = get_main_window()

View file

@ -204,6 +204,8 @@ class MaxCreator(Creator, MaxCreatorBase):
def create(self, subset_name, instance_data, pre_create_data):
if pre_create_data.get("use_selection"):
self.selected_nodes = rt.GetCurrentSelection()
if rt.getNodeByName(subset_name):
raise CreatorError(f"'{subset_name}' is already created..")
instance_node = self.create_instance_node(subset_name)
instance_data["instance_node"] = instance_node.name
@ -246,14 +248,25 @@ class MaxCreator(Creator, MaxCreatorBase):
def update_instances(self, update_list):
for created_inst, changes in update_list:
instance_node = created_inst.get("instance_node")
new_values = {
key: changes[key].new_value
for key in changes.changed_keys
}
subset = new_values.get("subset", "")
if subset:
if instance_node != subset:
node = rt.getNodeByName(instance_node)
new_subset_name = new_values["subset"]
if rt.getNodeByName(new_subset_name):
raise CreatorError(
"The subset '{}' already exists.".format(
new_subset_name))
created_inst["instance_node"] = new_values["subset"]
node.name = created_inst["instance_node"]
imprint(
instance_node,
new_values,
created_inst["instance_node"],
created_inst.data_to_store(),
)
def remove_instances(self, instances):