Jump to content
Sign in to follow this  

HDA python get selected menu item

Recommended Posts

Hi everyone,

this is my first time writing tools with python, so maybe I got something completely wrong here. I want to built a HDA to setup the houdini scene by selecting project, sequence and shot number. For that I created a HDA with a ordered menu and a drop down listing all available projects. The menu is created by a python function in the python module and then called in the menu script area. I then have another ordered menu to select from all the available sequences based on the selected project. A callback script on the project drop down is triggering the create menu function for the sequence drop down. I then need to know the currently selected project in the project drop down. I tried getting this information with the node eval parm, but this is only kind of working. It returns the right token, but as an integer and multiple times for each menu item causing a long loop. I also tried using the menu parm template, but I cannot access the data correctly.
What would be the best way to geht the menu label as a string for the currently selected item in the drop down menu?



Here is some of the code I used:

def projectMenu():
    import os
    projectPath = 'H:/'
    projectList = os.listdir(projectPath)
    for i, item in enumerate(projectList):
    return projectMenu

#Call function in menu script

#Callback function to trigger sequence menu in python module

def sequenceMenu(kwargs):
    import os
    node = kwargs['node']
    projSelect = node.parm('project').eval()


Share this post

Link to post
Share on other sites

There's a menuLabels function:


prjID = node.parm('project').eval()
prjName = node.parm('project').menuLabels()[prjID]


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this