Mzigaib Posted December 9, 2018 Share Posted December 9, 2018 I have a simple ordered menu that have python script that has a variable 'check', I want that a button on the same node changes the value of this variable, with hscript I just put 'set -p check=1' on the callback script and I can access this variable on my menu's script, how do I do that with python? I hope that makes sense. Thanks. Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted December 10, 2018 Author Share Posted December 10, 2018 I have my function on my ordered menu list: import os def listDirs(check): result = [] houDir = os.listdir(hou.getenv('JOB')+'/houdini') if check==1: for dir in houDir: result+=[dir,dir] return result else: result=["Nothing","Nothing"] return result return listDirs(check) I want my button on the same node to pass a value '1' to my 'check' variable in that function, how do I do that? I did try on a callback button: hou.pwd().parm('dirList').listDirs(1) But it didn't work, what am I missing? Thanks. Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted December 10, 2018 Author Share Posted December 10, 2018 No one? Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted December 10, 2018 Author Share Posted December 10, 2018 I think the right question should be how do I access the menu module script from a command button, everywhere I look just explain how to do that If I want to access the module in a digital asset which I think it is not the case. Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted December 11, 2018 Share Posted December 11, 2018 (edited) Seems like what you want is a semi-dynamic menu, which gets updated on request. You can do something along those lines: In the menu script: return hou.phm().my_menu_values(kwargs['node']) In your PythonModule: LIST_DIR = False def my_menu_values(node): if not node.cachedUserData('menu_values'): node.setCachedUserData('menu_values', read_dir_or_something()) if LIST_DIR: node.setCachedUserData('menu_values', read_dir_or_something()) return node.cachedUserData('menu_values') Then in your button callback: kwargs['node'].phm().LIST_DIR = True # force menu to cook kwargs['node'].parm('my_menu').menuItems() kwargs['node'].phm().LIST_DIR = False P.S. Untested Edited December 11, 2018 by Stalkerx777 Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted December 11, 2018 Author Share Posted December 11, 2018 Thank you so much for your time to explain me that I am totally gona try that, I didn't know that phm() module. I'll let you know what I got. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.