View Full Version : python/MEL query question

09 September 2010, 02:53 AM
This code will query whether a node has keyframes at a certain time. Then I can do various things to those keys. How do I query whether a particular channel has keys, to refine the query?

hasKey = mc.keyframe( selection, query=True, time=(theTime, theTime))
if hasKey != None:
print 'found keys!'

09 September 2010, 01:59 PM
er.. just query the particular channel..?

mc.keyframe( 'pCube.translateY', query=1)
additionally, animation keys are stored in animCurve nodes, so alternatively, depending on your scenario, if you want to check if a particular channel has keys, you could check if it is connected to an animCurve.

incidentally, python has an innate understanding of everything being either true or false, so it is not very pythonic to compare things when boolean testing.

if hasKey != None:is much better asif hasKey:and far easier to understand the intention!

09 September 2010, 03:24 PM
Thanks Nathan, great info!

CGTalk Moderation
09 September 2010, 03:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.