[pyhton] Total number of parms in a folder? (with nested folders included)

   1083   1   1
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
I need to know the amount of parameters of a multiparm block folder template.

So far I'm doing the following:
multiparmTemplate = node.parm("myMultiParmFolder").parmTemplate().parmTemplates()
nparms_eachBlock = len(multiparmTemplate) 
  1. The problem arises when you have a nested folder (with its own child parms) inside your multiparm folder. The above code would treat that folder as 1 single element.
    Is there a way to do it procedurally, without having to add-hardcode to the above result the number of items of the nested folder (number that can vary)?

  2. Bonus question: my ultimate goal is to know the Index of the multiparm block, given one of the parameter instances of the multiparm folder. (es. from “range3x” , it should return 3)
    I managed to do it in a convoluted way, with
    parm.multiParmInstanceIndices()[0]  / nparms_eachBlock
    
    but multiParmInstanceIndices() is accounting for the child paramaters of the nested Folder, and for the folder itself.
    So, if I can't have the exact number of items of the multiparm template folder, I should hardcode it. Maybe there's a function that I overlooked that can tell you the id of the multiparm block of provenience?
Thanks for any help!
Edited by Andr - Feb. 11, 2019 14:43:25
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Grave digg for the future users who might face the same issue

Andr
Bonus question: my ultimate goal is to know the Index of the multiparm block

So I eventually gave up with 1), still haven't find a solution,
I ended up doing some string formatting and splitting in order to extrapolate the index from the parm instance name.

But I just found out that you can just use key ‘script_multiparm_index’ from the kwargs dictionary.
http://www.sidefx.com/docs/houdini/hom/locations.html#parameter_callback_scripts [www.sidefx.com]

as simple as that
Edited by Andr - March 7, 2019 07:53:55
  • Quick Links