From e205262d3fb993cb05b5478b5d361ec1c2636b64 Mon Sep 17 00:00:00 2001 From: Ben Souchet Date: Wed, 11 Sep 2024 12:29:12 +0200 Subject: [PATCH] Maya Node Attrs Remap: Avoid crashes when attribute isn't settable or attr type isn't valid --- openpype/hosts/maya/api/lib.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/api/lib.py b/openpype/hosts/maya/api/lib.py index 6d4bda5d2ae..defee47ce0a 100644 --- a/openpype/hosts/maya/api/lib.py +++ b/openpype/hosts/maya/api/lib.py @@ -752,6 +752,9 @@ def attribute_values(attr_values): original = [(attr, cmds.getAttr(attr)) for attr in attr_values] try: for attr, value in attr_values.items(): + if not cmds.getAttr(attr, settable=True): + log.debug("can not set {}".format(attr)) + continue if isinstance(value, string_types): cmds.setAttr(attr, value, type="string") else: @@ -759,6 +762,9 @@ def attribute_values(attr_values): yield finally: for attr, value in original: + if not cmds.getAttr(attr, settable=True): + log.debug("can not set {}".format(attr)) + continue if isinstance(value, string_types): cmds.setAttr(attr, value, type="string") elif value is None and cmds.getAttr(attr, type=True) == "string": @@ -1581,7 +1587,10 @@ def set_attribute(attribute, value, node): """ value_type = type(value).__name__ - kwargs = ATTRIBUTE_DICT[value_type] + kwargs = ATTRIBUTE_DICT.get(value_type) + if not kwargs: + log.debug("Attribute type '{}' is not supported for {}".format(value_type, attribute)) + return if not cmds.attributeQuery(attribute, node=node, exists=True): log.debug("Creating attribute '{}' on " "'{}'".format(attribute, node))