Multiparms - how to set a default value from a expression ?

   1107   7   1
User Avatar
Member
24 posts
Joined: Dec. 2020
Online
Hello,

I'm going crazy trying to learn more about multiparms. I'm just starting with them and I don't have much knowledge of coding either. The test I'm working on is a loop where each multiparm instance creates a box, one on top of the other, with an independent uniform scale control (#).

The thing is, I would like the number of boxes to be driven by the value of an attribute from the HDA input. For example, if I connect the HDA to an input that has a "modules" value of 7, the HDA would automatically show me 7 boxes, each with a uniform scale control.

My problem is that in the "default" section for creating the multiparms, I can't get it to inherit or accept any expression to tell it to take the integer value of "modules" from input 0 as the default for the multiparm.

Do you know how to do this? Could you provide an example?

Thank you very much!

P.S.: Do you know of any tutorial or series of tutorials where I can learn more about multiparms, and see examples of HDAs to understand how to use them and their possibilities?

Thank you very much!!

Attachments:
multiparm.png (61.0 KB)

I love node based world

Learning and Playing houdini
User Avatar
Member
24 posts
Joined: Dec. 2020
Online
ok , i tried another test.

I have a multiparm name : cutsModule
and an attribute integer into the detail: nModules ( this attribute exist in the input 0 )

So i create in the hda scripts an On create . with this script :

node = kwargs
node.parm("cutsModule").setExpression('detail(0, "nModules", 0)')

----
it works fine without error messages . But the behavior with the caches its extrange. I don´t know why , if its for kwargs ...

So i tried to use this script:

node = hou.pwd()
node.parm("cutsModule").setExpression('detail(0, "nModules", 0)'

But it doesn´t work , when i create the node , there is an error message:

Error running event handler:
Traceback (most recent call last):
File "jsvde.dev::Sop/multiparm_value_default_test::10.0, opdef:/jsvde.dev::Sop/multiparm_value_default_test::10.0?OnCreated, node /obj/geo1/multiparm_value_default_test5", line 3, in <module>
AttributeError: 'NoneType' object has no attribute 'setExpression'

so i don´t know how can I attached an expresion to create a multiparm value depending on a value.
Edited by Jackatack - July 20, 2024 18:19:14

Attachments:
ONCREATED.png (66.0 KB)

I love node based world

Learning and Playing houdini
User Avatar
Member
8780 posts
Joined: July 2007
Offline
Jackatack
...
So i create in the hda scripts an On create . with this script :
node = kwargs["node"]
node.parm("cutsModule").setExpression('detail(0, "nModules", 0)')

it works fine without error messages . But the behavior with the caches its extrange. I don´t know why , if its for kwargs
...

this is the correct way to set expression on parameter during onCreated callback

you'll need to elaborate more on what you consider strange behavior
did it not create the correct expression on the parameter?

that being said having Multiparm count depend on attribute is a very bad idea so you don't really want to do that

since at any opportunity when during cooking of the expression the geo is not available (like when opening the scene in Manual or disconnecting the input or temporary error in input geo, ...) you will get 0 which will reset the multiparm instances and then even if at later time it gets the right value all the multiparm instances will be at default
Edited by tamte - July 20, 2024 19:35:11
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
24 posts
Joined: Dec. 2020
Online
tamte
Jackatack
...
So i create in the hda scripts an On create . with this script :
node = kwargs["node"]
node.parm("cutsModule").setExpression('detail(0, "nModules", 0)')

it works fine without error messages . But the behavior with the caches its extrange. I don´t know why , if its for kwargs
...

this is the correct way to set expression on parameter during onCreated callback

you'll need to elaborate more on what you consider strange behavior
did it not create the correct expression on the parameter?

that being said having Multiparm count depend on attribute is a very bad idea so you don't really want to do that

since at any opportunity when during cooking of the expression the geo is not available (like when opening the scene in Manual or disconnecting the input or temporary error in input geo, ...) you will get 0 which will reset the multiparm instances and then even if at later time it gets the right value all the multiparm instances will be at default
My intention is for a building made up of modules to be able to attach an HDA that allows each module of the building to be subdivided independently.

I thought it would be convenient for those multiparms to appear automatically depending on the number of modules.

I wouldn't mind if it returned to the default setting when disconnected.

The strange behavior is:
If I have 7 iterations (modules) and I attach the HDA, it correctly generates 7 multiparms.
The problem arises when I change the number of iterations. Instead of adding or removing multiparms, it causes the foreach to bug out, even if I reset each node.
It doesn't return a correct value until I disconnect the HDA or delete it, and then reset the cache of the foreach node.

I don't know if it's a bug or something that hasn't been thought through properly.

I have uploaded a .hip file and the HDA in case someone wants to reproduce the error/bug or can tell me what might be going wrong.

Best regards and thanks a lot for the response!!

Attachments:
sop_jsvde.dev.multiparm_value_default_test.12.0.hdalc (6.2 KB)
MULTIPARM_Default_AttribValue_v001.hiplc (159.2 KB)

I love node based world

Learning and Playing houdini
User Avatar
Member
8780 posts
Joined: July 2007
Offline
that's really an odd behavior and you should probably submit it as a bug as it's rare that something downstream that's only reading the attribute would affect upstream behavior in this way
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
24 posts
Joined: Dec. 2020
Online
Thanks!! I will report the bug to sidefx
I love node based world

Learning and Playing houdini
User Avatar
Member
24 posts
Joined: Dec. 2020
Online
tamte
that's really an odd behavior and you should probably submit it as a bug as it's rare that something downstream that's only reading the attribute would affect upstream behavior in this way

i reported the bug , but its not a bug:
This is the answer from side FX :

Hello,

Our developers comment:
You CANNOT animate the number of multiparms using the multiparm field. This includes driving it from geometry attributes, etc. This may appear to work where it can statically resolve a constant value, but cannot work as soon as you end up with a for each loop where it varies during execution.

Native Verb-based nodes that have multiparms can be overridden with the Parameter Override option, where the parameter override is built by a vex wrangle to override the multiparm. Attached shows an example building such an override for the Add SOP.

best company ever , in only 24 hours they send me an answer.

I upload the file , if someone wants to know the workaround

Attachments:
ptoverride.hip (114.7 KB)

I love node based world

Learning and Playing houdini
User Avatar
Member
8780 posts
Joined: July 2007
Offline
that doesn't really explain why the For Each loop breaks, since your foreach loop doesn't need to evaluate that multiparm during execution, so it should not break it

it's still a bug in my opinion, regardless of whether driving number of multiparms using attribute is a bad idea anyway or whether it would downright break the node with Multiparm itself, it should still not break the full loop execution that's upstream without any direct dependency on the multiparm in either direction

parameter overrides are cool, however they work only on verbs and their effect is invisible in UI so they are more technical workaround to make Compiled Graphs work than an user friendly way to override parameters
That also means Parameter overrides will not work on your HDA because HDAs don't have verbs
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links