Jump to content

HDA python get selected menu item


Polyxion

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?

 

Thanks

Here is some of the code I used:
 

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

#Call function in menu script
hou.pwd().hdaModule().projectMenu()

#Callback function to trigger sequence menu in python module
hou.phm().sequenceMenu(kwargs)

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




 

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...