Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Filtering key ticks in Maya timeline via script

andy.lathamCJTQT
Contributor

Filtering key ticks in Maya timeline via script

andy.lathamCJTQT
Contributor
Contributor

Hey!

 

If you select an object in Maya and highlight an attribute in the channel box, key ticks will be displayed on the timeline only for that attribute. I'd like to achieve the same result with a script (i.e. not needing to highlight the attribute in the channel box), but I can't find any way to do it. I can select the appropriate animation node and see just those key ticks, but I want to retain control of the object itself in the viewport at the same time.

 

Does anyone know how to achieve this?

 

Thanks!

Reply
Accepted solutions (1)
490 Views
6 Replies
Replies (6)

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

This is a python script that highlights an attribute by name in the channelbox:

 

import maya.cmds as mc

def selChannelInBox(c = ""):
    sel = mc.ls(selection = True)[-1]
    mc.channelBox("mainChannelBox", e = True, s ="{0}.{1}".format(sel, c))
    
selChannelInBox(c = "ty")

 

I hope this helps!

 

 

 

0 Likes

andy.lathamCJTQT
Contributor
Contributor

Thanks so much for this! It's exactly what I was looking for! 🙂

0 Likes

andy.lathamCJTQT
Contributor
Contributor

Actually, could anyone explain how the "s" flag in channelBox() works? It isn't mentioned in the documentation for some reason! @Kahylan 

 

I'm trying to work out how to select multiple channels.

0 Likes

Kahylan
Advisor
Advisor

The select Flag was introduced with the interface change from Maya 2015 to 2016, so it's not in the 2011 doc that first shows up on google.

 

https://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/channelBox.html

 

To select multiple attributes you just need to insert a list of strings with attribtue names instead of a single attribute name in the s flag

0 Likes

andy.lathamCJTQT
Contributor
Contributor

Thanks @Kahylan!

brentmc
Autodesk
Autodesk

Hi,

The -s/-select flag selects the attribute in the channel box.

Ooops, I see @Kahylan has already answered. What they said! 🙂

Brent McPherson
Principle Engineer