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

[QUAD] Maya Node Attrs Remap: Avoid crashes when attribute isn't settable or attr type isn't valid #6305

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,19 @@ 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:
cmds.setAttr(attr, value)
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":
Expand Down Expand Up @@ -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))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (94 > 79 characters)

return
if not cmds.attributeQuery(attribute, node=node, exists=True):
log.debug("Creating attribute '{}' on "
"'{}'".format(attribute, node))
Expand Down
Loading