Skip to content

Commit

Permalink
Merge pull request #307 from MonsieurGallo/spring_manager_fixes
Browse files Browse the repository at this point in the history
Makes store_preset fail if node is not a spring.
  • Loading branch information
miquelcampos authored Oct 16, 2023
2 parents 6226153 + a05161f commit 862e6ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
15 changes: 11 additions & 4 deletions release/scripts/mgear/animbits/spring_manager/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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))

Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions release/scripts/mgear/animbits/spring_manager/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 862e6ab

Please sign in to comment.