Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5911 from ynput/bugfix/The-context-data-not-being…
Browse files Browse the repository at this point in the history
…-updated-correctly-when-the-variant-data-has-been-changed

Max: fix the subset name not changing accordingly after the variant name changes
  • Loading branch information
moonyuet authored Nov 17, 2023
2 parents 19f0a77 + 3bd8b40 commit 6cefe85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 0 additions & 2 deletions openpype/hosts/max/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,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()
Expand Down
17 changes: 15 additions & 2 deletions openpype/hosts/max/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -246,14 +248,25 @@ def collect_instances(self):
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 and 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))
instance_node = new_subset_name
created_inst["instance_node"] = instance_node
node.name = instance_node

imprint(
instance_node,
new_values,
created_inst.data_to_store(),
)

def remove_instances(self, instances):
Expand Down

0 comments on commit 6cefe85

Please sign in to comment.