djbyun Posted December 1, 2013 Share Posted December 1, 2013 (edited) Hello, Does anybody know how to get the button parmeter's name itself using python, when the button is pressed? Thanks. Edited December 1, 2013 by djbyun Quote Link to comment Share on other sites More sharing options...
graham Posted December 1, 2013 Share Posted December 1, 2013 The callback field has a kwargs dictionary that contains things like the node and parm objects. Quote Link to comment Share on other sites More sharing options...
djbyun Posted December 2, 2013 Author Share Posted December 2, 2013 Graham, I tried to use kwargs['parm_name'] or kwargs['parm'].name(). But they didn't work. The only thing which worked in Python Module was kwargs['type']. Would you mind showing an example code for getting the button parmaters name when I push it? Thanks. DJ Quote Link to comment Share on other sites More sharing options...
graham Posted December 2, 2013 Share Posted December 2, 2013 kwargs shows lots of information for me when printed from the callback field: {'node': <hou.ObjNode of type null at /obj/null1>, 'script_value0': '1', 'script_value': '1', 'script_multiparm_index': '-1', ' script_multiparm_nesting': '0', 'script_parm': 'myparm', 'parm': <hou.Parm myparm in /obj/null1>, 'parm_name': 'myparm'} If you are trying to access this information inside a function in the PythonModule, you would need call the function from the callback field and pass kwargs as the function argument. kwargs inside a PythonModule only gives you the node type information, as you've seen. button_test.hip 1 Quote Link to comment Share on other sites More sharing options...
djbyun Posted December 2, 2013 Author Share Posted December 2, 2013 Graham, It works pretty well. I could understand more clearly how kwargs works from your example file. I really appreciate it for your help. DJ 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.