Bases: MayaInstancePlugin
, OptionalPyblishPluginMixin
Validate rig control curves have no keyable arnold attributes.
The Arnold plug-in will create curve attributes like
- aiRenderCurve
- aiCurveWidth
- aiSampleRate
- aiCurveShaderR
- aiCurveShaderG
- aiCurveShaderB
Unfortunately these attributes visible in the channelBox are keyable by default and visible in the channelBox. As such pressing a regular "S" set key shortcut will set keys on these attributes too, thus cluttering the animator's scene.
This validator will ensure they are hidden or unkeyable attributes.
Source code in client/ayon_maya/plugins/publish/validate_rig_controllers_arnold_attributes.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 | class ValidateRigControllersArnoldAttributes(plugin.MayaInstancePlugin,
OptionalPyblishPluginMixin):
"""Validate rig control curves have no keyable arnold attributes.
The Arnold plug-in will create curve attributes like:
- aiRenderCurve
- aiCurveWidth
- aiSampleRate
- aiCurveShaderR
- aiCurveShaderG
- aiCurveShaderB
Unfortunately these attributes visible in the channelBox are *keyable*
by default and visible in the channelBox. As such pressing a regular "S"
set key shortcut will set keys on these attributes too, thus cluttering
the animator's scene.
This validator will ensure they are hidden or unkeyable attributes.
"""
order = ValidateContentsOrder + 0.05
label = "Rig Controllers (Arnold Attributes)"
families = ["rig"]
optional = False
actions = [RepairAction,
ayon_maya.api.action.SelectInvalidAction]
attributes = [
"rcurve",
"cwdth",
"srate",
"ai_curve_shaderr",
"ai_curve_shaderg",
"ai_curve_shaderb"
]
def process(self, instance):
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError('{} failed, see log '
'information'.format(self.label))
@classmethod
def get_invalid(cls, instance):
controls_set = instance.data["rig_sets"].get("controls_SET")
if not controls_set:
return []
controls = cmds.sets(controls_set, query=True) or []
if not controls:
return []
shapes = cmds.ls(controls,
dag=True,
leaf=True,
long=True,
shapes=True,
noIntermediate=True)
curves = cmds.ls(shapes, type="nurbsCurve", long=True)
invalid = list()
for node in curves:
for attribute in cls.attributes:
if cmds.attributeQuery(attribute, node=node, exists=True):
plug = "{}.{}".format(node, attribute)
if cmds.getAttr(plug, keyable=True):
invalid.append(node)
break
return invalid
@classmethod
def repair(cls, instance):
invalid = cls.get_invalid(instance)
with lib.undo_chunk():
for node in invalid:
for attribute in cls.attributes:
if cmds.attributeQuery(attribute, node=node, exists=True):
plug = "{}.{}".format(node, attribute)
cmds.setAttr(plug, channelBox=False, keyable=False)
|