kleer001 Posted March 12, 2015 Share Posted March 12, 2015 (edited) Is there any way to create an incremental +/- button in a parameter? Click + and the value goes up, clink - and the value goes down. Edited March 12, 2015 by kleer001 Quote Link to comment Share on other sites More sharing options...
Skybar Posted March 12, 2015 Share Posted March 12, 2015 (edited) Maybe not the most elegant solution, and I don't know if it's what you had in mind.. But you could do something like this: parmInc_dv.hipnc Edited March 12, 2015 by Skybar Quote Link to comment Share on other sites More sharing options...
ayidi Posted March 13, 2015 Share Posted March 13, 2015 Solution 1 (hack) - Create the buttons in the Edit Parameter Interface. - Use the Callback Script to update the value your parameter. - You can put the code in the small box but the gui removes newlines! - So if writing python add semi-colons (hack) parm = hou.parm('tx'); increment = parm.evalAsFloat() + 1; parm.set(increment) Solution 2 Proper way is to create a new custom operator that way it's more reusable. Option 1: Reference a function from HDA Module. Write the function inside Scripts (Event Handler: Python Module) and then call it in the callback: kwargs['node'].hdaModule().onButtonPress() Option 2: - Add a script file reference it with opdef: - Not worth the hazzle. Just do option 1. Solution 3 (hack) Use a script to insert the code bypassing the gui. http://forums.odforce.net/topic/9607-buttons-callback-script/?p=63084 1 Quote Link to comment Share on other sites More sharing options...
ayidi Posted March 13, 2015 Share Posted March 13, 2015 I've update skybar example to include solution 1 above: parmInc_dv2.hipnc 2 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 13, 2015 Share Posted March 13, 2015 It's slightly unrelated but can you get the currently edited parameter in Python and then modify it? That would allow you to increment values using hotkeys. I assume this can't be done. Quote Link to comment Share on other sites More sharing options...
ayidi Posted March 13, 2015 Share Posted March 13, 2015 (edited) It's slightly unrelated but can you get the currently edited parameter in Python and then modify it? That would allow you to increment values using hotkeys. I assume this can't be done. You can but the hotkey can't be just `+` or `-` Using PARMmenu.xml create a new entry with a script to increment the param value and assign it a hotkey. Edited March 13, 2015 by ayidi 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 13, 2015 Share Posted March 13, 2015 Thanks so just to be sure, I will for example select a node, click inside a parameter field like Scale, and then press the hotkey I assigned and it will operate on the active field, i.e. to set it to a fixed value, double it, etc? Not by right clicking the menu item? If so, I will get to it right away Quote Link to comment Share on other sites More sharing options...
ayidi Posted March 13, 2015 Share Posted March 13, 2015 select a node, click inside a parameter field like Scale, and then press the hotkey I assigned and it will operate on the active field, i.e. to set it to a fixed value, double it, etc That's correct. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 13, 2015 Share Posted March 13, 2015 Ok I checked that file and it seems logical but I don't know where my script will reside and how I will link it to the menu? If I understand it correctly, the name of my shelf button (not label) for example will be the id name I will use in the menu file? Quote Link to comment Share on other sites More sharing options...
ayidi Posted March 13, 2015 Share Posted March 13, 2015 (edited) Ok I checked that file and it seems logical but I don't know where my script will reside and how I will link it to the menu? If I understand it correctly, the name of my shelf button (not label) for example will be the id name I will use in the menu file? You stole the thread. Create a file named PARMmenu.xml with the following and place it in your Houdini preference folder or next to your .hip file. <?xml version="1.0" encoding="UTF-8"?> <menuDocument> <menu> <addScriptItem id="parm_increment"> <label>Increment</label> <parent>root_menu</parent> <insertBefore>copy_parm</insertBefore> <scriptCode><![CDATA[# Increment Script for parm in kwargs['parms']: parmType = parm.parmTemplate().type() if parmType == hou.parmTemplateType.Int: parm.set(parm.evalAsInt() + 1) elif parmType == hou.parmTemplateType.Float: parm.set(parm.evalAsFloat() + 1) ]]></scriptCode> </addScriptItem> <addScriptItem id="parm_decrement"> <label>Decrement</label> <parent>root_menu</parent> <insertBefore>copy_parm</insertBefore> <scriptCode><![CDATA[# Decrement Script for parm in kwargs['parms']: parmType = parm.parmTemplate().type() if parmType == hou.parmTemplateType.Int: parm.set(parm.evalAsInt() - 1) elif parmType == hou.parmTemplateType.Float: parm.set(parm.evalAsFloat() - 1) ]]></scriptCode> </addScriptItem> </menu> </menuDocument> Edited March 13, 2015 by ayidi Quote Link to comment Share on other sites More sharing options...
magneto Posted March 13, 2015 Share Posted March 13, 2015 Thanks a lot man, it works. I am sure kleer will be interested in this trick as well When I try to assign it a hotkey though, Houdini doesn't let me. This is what I see, but I can't click the Assigned Keys section as there is nothing selected in the middle section of that dialog. Quote Link to comment Share on other sites More sharing options...
ayidi Posted March 13, 2015 Share Posted March 13, 2015 Remove the "h." so its id="parm_decrement" Quote Link to comment Share on other sites More sharing options...
magneto Posted March 24, 2016 Share Posted March 24, 2016 Does anyone know how to hide a particular menu item? I tried using expression tag but it doesn't work. I used this: <expression>return False</expression> Is there a different way to do this? 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.