Python / Multiparm & Json

   2468   4   0
User Avatar
Member
35 posts
Joined: Feb. 2017
Offline
Hello,

I need your help with python & multiparm, please.

I want to be able to export a json file with all my multiparms with values.
Currently when I use for “parent.parms()” I have all the content of hda.
But how to ask by multiparm(tab) as I can when I ask parent.parmsInFolder()
All multiparms are stored on different folders, when I ask those folders I've no result.

I'm an absolute beginner on Python :/
Thanks in advance for your help & time.


User Avatar
Member
35 posts
Joined: Feb. 2017
Offline
I'm sorry if my question is too basic, but I need to find a way to extract multiparm values on json.
User Avatar
Member
8568 posts
Joined: July 2007
Offline
here is a quick function that will gather parameters within specified folder
it's a bit naive as would probably not work as is for nested multiparms or specific folder if more are named the same, but should get you going:
def getAllParmsInFolder(node, folder=""):
    parms = node.parms()
    if folder == "":
        return parms
    else:
        out_parms = []
        for parm in parms:
            if parm.isMultiParmInstance():
                mp = parm.parentMultiParm()
                folders = mp.containingFolders()
                if folder in folders:
                    out_parms.append(parm)
        return out_parms
        
        
node = hou.node('/your/node')
parms = getAllParmsInFolder(node, "Line 1")
Edited by tamte - June 15, 2020 00:26:07
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
35 posts
Joined: Feb. 2017
Offline
thanks a lot, Tamte
User Avatar
Member
35 posts
Joined: Feb. 2017
Offline
I've made a simple test case for multiparm folder.
I try using your code but I'm maybe wrong with the parameters I give. It doesn't compile.

I do not know if it's inside the python
here :
node = hou.node(“/../geo1/subnet1/output0”)
parms = getAllParmsInFolder(node, “Amount”)

or
when I call it on my button

Edited by innocent - June 23, 2020 09:43:52

Attachments:
multibox_py.hdalc (10.6 KB)

  • Quick Links