From 68e08aa482d269eab078c70d288fc1af9c0deeea Mon Sep 17 00:00:00 2001 From: Cesar Gallo Date: Fri, 13 Oct 2023 17:29:13 -0600 Subject: [PATCH 1/2] Makes store_preset fail if node is not a spring. Corrects mapping from namespaceless node to node with namespace --- .../mgear/animbits/spring_manager/setup.py | 15 +++++++++++---- .../scripts/mgear/animbits/spring_manager/ui.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/release/scripts/mgear/animbits/spring_manager/setup.py b/release/scripts/mgear/animbits/spring_manager/setup.py index dd37e1c3..65977f01 100644 --- a/release/scripts/mgear/animbits/spring_manager/setup.py +++ b/release/scripts/mgear/animbits/spring_manager/setup.py @@ -412,8 +412,8 @@ def get_config(node): # TODO: get child node name from the spring members # child_node = pm.listRelatives(node, c=True) if not pm.hasAttr(node, "springSetupMembers"): - print("{} doesn't have springSetupMembers attr, skipping...".format(node)) - return + print("{} doesn't have springSetupMembers attr".format(node)) + return False child_node = pm.listConnections(node.springSetupMembers[2])[0] direction = get_child_axis_direction(child_node) config = { @@ -434,7 +434,11 @@ def store_preset(nodes, filePath=None): preset_dic['configs'] = {} for node in nodes: - preset_dic['configs'][node.name()] = get_config(node) + node_config = get_config(node) + if config is False: + pm.error("Error on preset. Node '{}' is not a spring.".format(node.name())) + return + preset_dic['configs'][node.name()] = node_config print("file_path = {}".format(filePath)) @@ -478,7 +482,10 @@ def apply_preset(preset_file_path, namespace_cb): for key, config in preset_dic["configs"].items(): node = key if replace_namespace: - node = node.replace(preset_namespace, selection_namespace) + if ':' not in node: + node = selection_namespace + node + else: + node = node.replace(preset_namespace, selection_namespace) if not pm.objExists(node): mgear.log("Node '{}' does not exist, skipping".format(node)) continue diff --git a/release/scripts/mgear/animbits/spring_manager/ui.py b/release/scripts/mgear/animbits/spring_manager/ui.py index 1175fe8f..63c74ce2 100644 --- a/release/scripts/mgear/animbits/spring_manager/ui.py +++ b/release/scripts/mgear/animbits/spring_manager/ui.py @@ -407,7 +407,7 @@ def _namespace_confirmation_dialogue(self, preset_namespace, selected_namespace) message_box.setWindowTitle("Namespace mismatch") message_box.setText("Namespace from selection does not match the namespace stored in the preset.") - message_box.setInformativeText("Click Accept to map nodes from preset namespace '{}' ".format(preset_namespace) + message_box.setInformativeText("Click Apply to map nodes from preset namespace '{}' ".format(preset_namespace) + "\n to selected namespace '{}'".format(selected_namespace)) message_box.setStandardButtons(QtWidgets.QMessageBox.Apply | QtWidgets.QMessageBox.Ignore) From a05161fe3a8bc7ea3328a0b41c5baef96542f991 Mon Sep 17 00:00:00 2001 From: Cesar Gallo Date: Mon, 16 Oct 2023 14:04:40 -0600 Subject: [PATCH 2/2] Fixes for python 2 --- release/scripts/mgear/animbits/spring_manager/ui.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release/scripts/mgear/animbits/spring_manager/ui.py b/release/scripts/mgear/animbits/spring_manager/ui.py index 63c74ce2..b8fe328d 100644 --- a/release/scripts/mgear/animbits/spring_manager/ui.py +++ b/release/scripts/mgear/animbits/spring_manager/ui.py @@ -58,7 +58,7 @@ def create_actions(self): # Delete actions self.delete_selected_action = QtWidgets.QAction("Delete Selected Spring", self) - self.delete_all_action = QtWidgets.QAction("Delete All Springs") + self.delete_all_action = QtWidgets.QAction("Delete All Springs", self) # preset actions self.set_lib_action = QtWidgets.QAction("Set Library", self) @@ -87,9 +87,9 @@ def create_widgets(self): # directions self.directions_group_box = QtWidgets.QGroupBox("Directions") - directions = ["x", "y", "z", "-x", "-y", "-z"] + self.directions = ["x", "y", "z", "-x", "-y", "-z"] self.direction_buttons = {} - for direction in directions: + for direction in self.directions: btn = QtWidgets.QPushButton(direction) self.direction_buttons[direction] = btn @@ -157,8 +157,8 @@ def create_layout(self): main_layout.setMenuBar(self.menu_bar) directions_grid_layout = QtWidgets.QGridLayout() - for i, direction_btn in enumerate(self.direction_buttons.values()): - directions_grid_layout.addWidget(direction_btn, i // 3, i % 3) + for i, direction in enumerate(self.directions): + directions_grid_layout.addWidget(self.direction_buttons[direction], i // 3, i % 3) self.directions_group_box.setLayout(directions_grid_layout) main_layout.addWidget(self.directions_group_box)