In this blog I will show how you can make a multi parameter block. This can be really useful to have in a HDA.
A Multi parameter block allows you to create a list of multiple parameters.
The gif below is a small demo of what you can do.
Making the multi parameter
First you can make a HDA and go in the Type Properties. Once in that menu create a folder, in the settings of the folder change type to Multiparm Block.
Adding new parameters in the folder will create automatically a "#" behind the parameters once Apply is pressed. The # shows that it will be a list of multiple parameters. If parameters are created the # will be replaced with numbers based on how many parameters you add.
Also the ui will change on the type of Multiparm Block you choose. In the image below you can see the difference.
By clicking on the plus and minus buttons you can control the amount of the parameters. Every time you press plus it will duplicate all the parameters in the folder you made in the HDA.
Using the parameters
Once you added new parameters, you want to use them to control nodes.
As example I will make a system to add boxes and scale them individually. Normally if you want to reference parameters it would look something like this : ch("../scale1") . But with a list parameters that can be changed any moment this will not work.
What you need is a for each number (SOP), this will loop based on a number you give. The number in this case is the amount of parameters, which can be found in the folder. So reference the folder, ch("../FolderName"), in the foreach end sop in the iteration parameter. Now it will loop based on how many parameters you create.
Further you can use the for each loop to control the parameters that you create, example here I want to control parameter scale1 to scale10.
By using the current number of loop (or iteration) you can get the values of each parameter. The default way to acces the current loop number is this.
detail("../foreach_count1","iteration", 0)
Then you need to combine this number with the reference to the scale ( ch("../scale#"). By using an expression in the transform SOP you can combine these two strings together. The expression is strcat , this will return a combined version of two strings.
Using the following line in the scale of the transform SOP, the loop will go over each parameter and get the correct value;
ch(strcat("../scale",detail("../foreach_count1","iteration", 0) +1))
Notice that scale# is typed without the #, so the strcat will take care of filling in the number based on the iteration.
Overall using a multiparm block can be very useful if you need to control the amount of parameters. This can open a lot of possibilities and it doesn't require a lot of manual work as you can use loops.
That was it for this week!
Hope you learned something new and see you on the next one.