By Jarom Brand
Does anyone know how to get a list of all the attributes that show up in the channelBox? I have something that works for transforms, but if I try it on shapes I get way more than I want.
This is what I have so far:
import pymel.core as pm def getChannelBoxAttrs(obj): ''' Returns a list of all the visible attributes @param PyNode: object The ojects whoes attributes will be toggled @return list: Returns a list of the attributes in the channelBox ''' visible_attrs =  attribs = obj.listAttr(k=True, u=True) attribs.extend(obj.listAttr(k=True, l=True)) attribs.extend(obj.listAttr(cb=True)) #remove the parent transform attributes from the list parent_attrs = ['translate', 'rotate', 'scale'] for attrib in attribs: if not attrib.attrName(longName=True) in parent_attrs: visible_attrs.append(attrib) return visible_attrs obj = pm.selected() getChannelBoxAttrs(obj)
If I have a shape selected when I run this I will get this as a return:
# Result: [Attribute(u'nurbsCircleShape1.controlPoints[-1].xValue'), Attribute(u'nurbsCircleShape1.controlPoints[-1].yValue'), Attribute(u'nurbsCircleShape1.controlPoints[-1].zValue'), Attribute(u'nurbsCircleShape1.uvSet[-1].uvSetName'), Attribute(u'nurbsCircleShape1.colorSet[-1].colorName'), Attribute(u'nurbsCircleShape1.colorSet[-1].clamped'), Attribute(u'nurbsCircleShape1.colorSet[-1].representation'), Attribute(u'nurbsCircleShape1.aiUserOptions'), Attribute(u'nurbsCircleShape1.aiTraceSets'), Attribute(u'nurbsCircleShape1.aiSssSetname'), Attribute(u'nurbsCircleShape1.aiRenderCurve'), Attribute(u'nurbsCircleShape1.aiCurveWidth'), Attribute(u'nurbsCircleShape1.aiSampleRate'), Attribute(u'nurbsCircleShape1.aiCurveShader'), Attribute(u'nurbsCircleShape1.aiCurveShaderR'), Attribute(u'nurbsCircleShape1.aiCurveShaderG'), Attribute(u'nurbsCircleShape1.aiCurveShaderB')] # Even though most of those don't actually show up in the channelBox.
Also If anyone has a more elegant way of stripping out parent attributes, I'd love to see it. I never like hard coding things like that.
By Jarom Brand
Ever since Autodesk included Arnold in maya, every NURBS curveShape now has these attributes:
aiRenderCurve aiCurveWidth aiSampleRate aiCurveShaderR aiCurveShaderG aiCurveShaderB
I like to place instanced NURBS curveShapes under controls to give animators access to the same attributes across multiple controls, say a fk/ik switch. So, to clean things up, I will lock and hide those new attributes and add my own:
For the most part this works great, but those attributes that I locked and hid will randomly pop back into the Channel Box on their own.
I assume it has something to do with Arnold plugin and that its putting them back, but I'd like to stop that from happening. Any Ideas?