merlino Posted April 1, 2016 Share Posted April 1, 2016 Hi guys, I'm trying to create a shelf button that quickly create a parameter into the selected node. To start, I'm happy with the initial solution, taken from https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=22539 n = hou.selectedNodes()[0] group = n.parmTemplateGroup() n_fol = hou.ui.readInput("Folder name: ", title=('Add Float:'))[1] n_par = hou.ui.readInput("Parm name: ", title=('Add Float:'))[1] folder = hou.FolderParmTemplate(n_fol, n_fol) folder.addParmTemplate(hou.FloatParmTemplate(n_par, n_par, 1)) group.append(folder) n.setParmTemplateGroup(group) but I have a problem, when I run again to add a second parameter, the folder takes name from the first one adding '_1' instead of taking the name I put in the folder name. The label it's ok, with the name I insert. Any idea why is this happening? Thanks! Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted April 7, 2016 Share Posted April 7, 2016 (edited) Hi guys, I'm trying to create a shelf button that quickly create a parameter into the selected node. To start, I'm happy with the initial solution, taken from https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=22539 n = hou.selectedNodes()[0] group = n.parmTemplateGroup() n_fol = hou.ui.readInput("Folder name: ", title=('Add Float:'))[1] n_par = hou.ui.readInput("Parm name: ", title=('Add Float:'))[1] folder = hou.FolderParmTemplate(n_fol, n_fol) folder.addParmTemplate(hou.FloatParmTemplate(n_par, n_par, 1)) group.append(folder) n.setParmTemplateGroup(group) but I have a problem, when I run again to add a second parameter, the folder takes name from the first one adding '_1' instead of taking the name I put in the folder name. The label it's ok, with the name I insert. Any idea why is this happening? Thanks! Generally you should not care about folder names, only Labels are important, 99% of the time working with parm templates. Houdini manages those names automagically somehow Edited April 7, 2016 by Stalkerx777 1 Quote Link to comment Share on other sites More sharing options...
Atom Posted April 16, 2016 Share Posted April 16, 2016 You need to check if the folder/item exists before you blindly create a new one. If it does exist, fetch the existing one instead of creating a new one. Otherwise default name management will haunt you and multiple copies will build up. For instance, you should examine group before you append to it. 1 Quote Link to comment Share on other sites More sharing options...
merlino Posted May 2, 2016 Author Share Posted May 2, 2016 Hey guys! Thanks a lot for the replies! I'll soon make a test and let you know the new (hopefully) working version. Alexey, thank you really much, the start point for my code is your! Tanks! 1 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.