Skip to content

Commit

Permalink
Channel Master: store and reset to creation value #74
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcampos committed Jan 25, 2023
1 parent d601ddb commit da0b6a7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
26 changes: 18 additions & 8 deletions release/scripts/mgear/animbits/channel_master_utils.py
Expand Up @@ -105,7 +105,7 @@ def get_single_attribute_config(node, attr):

# Get value at channel creation time
# this value can be different from the default value
config["creationValue"] = cmds.getAttr(attr)
config["creationValue"] = cmds.getAttr("{}.{}".format(node, attr))

return config

Expand Down Expand Up @@ -170,14 +170,24 @@ def reset_attribute(attr_config, namespace=None):
attribute.reset_selected_channels_value(objects=[obj], attributes=[attr])


# def reset_creation_value_attribute(attr_config, namespace=None):
# """Reset the value of a given attribute for the attribute configuration
def reset_creation_value_attribute(attr_config, namespace=None):
"""Reset the value of a given attribute for the attribute configuration
# Args:
# attr_config (dict): Attribute configuration
# """
# ctl = get_ctl_with_namespace(attr_config, namespace=None)
# return ctl
Args:
attr_config (dict): Attribute configuration
"""
ctl = get_ctl_with_namespace(attr_config, namespace=None)
attr = attr_config["longName"]
fullname_attr = "{}.{}".format(ctl, attr)
if "creationValue" in attr_config.keys():
val = attr_config["creationValue"]
cmds.setAttr(fullname_attr, val)
else:
pm.displayWarning(
"Initial Creation Value was not originally stored for {}".format(
fullname_attr
)
)


def sync_graph_editor(attr_configs, namespace=None):
Expand Down
8 changes: 8 additions & 0 deletions release/scripts/mgear/animbits/channel_master_widgets.py
Expand Up @@ -94,6 +94,14 @@ def create_menu(self):
reset_value_action.setIcon(pyqt.get_icon("mgear_rewind"))
reset_value_action.triggered.connect(self.reset_value_slot)
self.menu.addAction(reset_value_action)
reset_creation_value_action = QtWidgets.QAction(
"Reset to Creation Value", self
)
reset_creation_value_action.setIcon(pyqt.get_icon("mgear_rewind"))
reset_creation_value_action.triggered.connect(
self.reset_creation_value_slot
)
self.menu.addAction(reset_creation_value_action)
self.menu.addSeparator()

sync_graph_editor_action = QtWidgets.QAction(
Expand Down

0 comments on commit da0b6a7

Please sign in to comment.