Hiro11 0 Posted February 17, 2020 (edited) import hou import pprint node = hou.node('/obj/geo1/subnet2/TestNode') number = 5 parm_tuple = node.parmTuples()[number] name = [parm.name() for parm in parm_tuple] group = node.parmTemplateGroup() parm_template = group.entriesWithoutFolders()[number] myIndex = group.containingFolderIndices(parm_template) folder = group.entryAtIndices(myIndex) ContFolder = group.containingFolder(parm_template) name = ContFolder.name() label = ContFolder.label() node = hou.node('/obj/geo1/subnet2') group = node.parmTemplateGroup() folder = hou.FolderParmTemplate(name, label) folder.addParmTemplate(parm_template) group.append(folder) node.setParmTemplateGroup(group) I am not a python guy, and I'm stuck and need some help. What I want to do is, I want to make a custom HDA that has a node(ex.Mantra) inside, and I want to copy all the parm(+folders) in the Mantra Node,and paste it in the HDA parameter. Also I want to reference it each. I tried and figured out how to copy the parm and folder,but when I do this to all the parm,it will make a lot of folder with the same name... Is there any good way to do this? I want do it with python. Thanks, Hiro Edited February 17, 2020 by Hiro11 Share this post Link to post Share on other sites
Hiro11 0 Posted February 19, 2020 import hou import pprint parent = kwargs["node"] parent_path = ("../" + parent.name()) children = parent.children() child = children[0] child_path = ( parent_path + "/" + child.name()) node = child number = len(node.parmTuples()) def first(): for i in range(number): parm_tuple = node.parmTuples()[i] parm_template = parm_tuple.parmTemplate() parm_type = parm_template.type() if parm_type == hou.parmTemplateType.FolderSet: name = parm_template.name() label = parm_template.folderNames() type = parm_template.folderType() parent_node = parent group = parent_node.parmTemplateGroup() group.addParmTemplate(hou.FolderParmTemplate( name, label[0], folder_type=type)) parent_node.setParmTemplateGroup(group) elif parm_template in node.parmTemplateGroup().entries(): parent_node = parent group = parent_node.parmTemplateGroup() group.append(parm_template) parent_node.setParmTemplateGroup(group) else: print("None") first() def second(): for i in range(number): parm_tuple = node.parmTuples()[i] parm_template = parm_tuple.parmTemplate() parm_type = parm_template.type() if not (parm_type == hou.parmTemplateType.FolderSet) and not (parm_template in node.parmTemplateGroup().entries()): group = node.parmTemplateGroup() print(group) folder = group.containingFolder(parm_template).label() parent_node = hou.node('/obj/geo1/TestForPython_HDA') group = parent_node.parmTemplateGroup() folder = group.findFolder(folder) group.appendToFolder(folder, parm_template) parent_node.setParmTemplateGroup(group) second() def reference(): parm_count = len(node.parms()) pprint.pprint(parm_count) for i in range(parm_count): name = node.parms()[i] pprint.pprint(name) reference = (child_path + "/" + name.name()) handler = (parent_path + "/" + name.name()) channel = ('ch' + '(\"../' + name.name() + '\")') if name == node.parms()[i]: name.setExpression(channel) reference() I think I got it. There is some trouble sometimes.(Dont know why)But,needs time to figure out why it sometimes gets an error... Share this post Link to post Share on other sites
LucaScheller 61 Posted February 19, 2020 Don't know if this is of interest to you, but there is actually already a feature built into Houdini that does that: Not sure if you can refresh it though via Python dynamically. Here's an old thread about it https://www.sidefx.com/forum/topic/34941/?page=1#post-290083. Houdini Wiki > Search for Import Blocks https://www.sidefx.com/docs/houdini/ref/windows/optype.html 2 Share this post Link to post Share on other sites
Hiro11 0 Posted February 27, 2020 @LucaScheller Hi,Sorry for the late reply. I did not know this.I think I will do it this way.I am so happy to know this!! I did finish the python way,but its not a very good way I think... Also I am not a python guy,,,(cry) The refresh with python, It would be best to do it,but I cant find anyway to,,,So I think I will do it by hand. Thanks, Hiro Share this post Link to post Share on other sites
LucaScheller 61 Posted February 27, 2020 (edited) No problem, you can also look into how the TOP>hdaprocessor node does it. (You can select an .hda and it then rebuilds the parms in the "HDA Parameters" Tab). Edited February 27, 2020 by LucaScheller Share this post Link to post Share on other sites
Hiro11 0 Posted February 28, 2020 @LucaScheller Thanks!I will look at it! Share this post Link to post Share on other sites