Get selected channel in graph with Python

   511   2   2
User Avatar
Member
2 posts
Joined: 11月 2017
Online
Hi, everyone!

after a long day of struggling I have reached a wall and looking for help. I need to get a name of parm of selected channel with Python, but had no luck with that.

Maybe someone is familiar with ChannelGraph [www.sidefx.com] class?

Strangely a simple example with keyframes in Houdini's help, doesn't work either:

import hou
channel_editor = hou.ui.paneTabOfType(hou.paneTabType.ChannelEditor)
keyframes = channel_editor.graph().selectedKeyframes()
for parm in keyframes.keys():
    for key in keyframes[parm]:
        key.setValue(2 * key.value())
        parm.setKeyframe(key)


Thanks!
User Avatar
スタッフ
62 posts
Joined: 1月 2022
Offline
Hi, I just tried that snippet and it seems to work fine for me, and I'm able to get the name of the parm with
parm.name()
.

Do you now which part is failing? Is the keyframes.keys() dictionary empty?

Just to double check, you're trying to get the name of a channel for which you've selected keys in the graph itself, right? If it's just selected in the channel list you can instead do something like:

import hou
channel_list = hou.playbar.channelList()
for parm in channel_list.parms():
    if channel_list.isSelected(parm):
        parm.name()
Edited by michaelf - 2023年11月23日 11:57:34
User Avatar
Member
2 posts
Joined: 11月 2017
Online
Hi, michaelf,

correct, I am getting just an empty dictionary in keyframes variable "dict_keys()". Still have no idea, why it doesn't work for me. Your suggestion to use hou.playbar.channelList() works great for my case. Many thanks!!!
  • Quick Links