[QUOTE=Wuffles;17579]Hey Age,
I had a look at this. Needless to say my Maya scripting knowledge is limited atm. It does seem like it’s not working as intended, as it will return True if the attribute is not keyable, but False when it is and for everything else (lock,hide).
The documentation is quite vague about what the command actually does (doesn’t use the word visible but show instead) as well as it mentioning that keyable attributes are shown.
I tried to query it using the attributeQuery command as well and even though it recognises the attribute it doesn’t seem to recognise if it’s keyable or hidden either.
To answer your question - I’m not sure how else you’d query for the visibility of the channel. This link here seems to allude to the function working however I can’t seem to get it to work. :o(
http://www.cgmonks.com/tag/settools/ - (first post)
Here is the code I was using anyway…
import maya.cmds as cmds
objAttr = "obj.testAttr"
def getAttrStatus():
if cmds.getAttr(objAttr,lock=1)==1 and cmds.getAttr(objAttr,cb=1)==1: # locked but visible
print("I'm locked but you can see me! ")
else:
print "Returned false"
Sorry I couldn’t help. :([/QUOTE]
Hi! and thanks for your help!
So I’ve learned that for some reason (probably a bug) Maya associates the keyable flag with the channelBox flag.
Long story short I found this backwards way of seeing if an attribute is locked but visible in channelBox, and here it is:
if getAttr(‘obj.attr’,l=1) and not getAttr(‘obj.attr’,k=1): # locked and hidden
state = 0
elif getAttr(‘obj.attr’,l=1) and getAttr(‘obj.attr’,k=1) : # locked and visible
state = 1
elif getAttr(‘obj.attr’,k=1) : # keyable
state = 2
Just a side note:
In your code:
if cmds.getAttr(objAttr,lock=1)==1 and cmds.getAttr(objAttr,cb=1)==1: # locked but visible
You dont have to say “==1”. Python assumes it equals 1 if you say “if”.
so this would work the same:
if cmds.getAttr(objAttr,lock=1) and cmds.getAttr(objAttr,cb=1): # locked but visible
or…
is_locked = cmds.getAttr(objAttr,lock=1)
cb_visible = cmds.getAttr(objAttr,cb=1)
if is_locked and cb_visible : # locked but visible