Jump to content

Dynamically create parameters on a node (i.e. subnet)?


chiess

Recommended Posts

Hi,

At the moment, I have a simple NURBS line with 2 control points. This setup is stored in a subnet. The position of these 2 points can be modified via parameters on the subnet (basically each of them is linked to a transform node).

But, to make it better, I want to choose the number of control points my line could have. In that case, I need more position-parameters on the subnet to control each of these points.

Is there a way to dynamically create new parameters on a node?

For example, I give the "Number of control points"-parameter the number 4, which means, I want to have 4 control points on my line.

How can I dynamically add 4 additional parameters to the subnet, each controlling another point. Maybe via python? Examples would always be helpful, but an advice towards the right direction would also help a lot.

(I was thinking of adding transform nodes with a foreach node. In that case each of them has its own transform node. I then need to feed in the control point number and link it to the correct parameters on the subnet-node)

Thanks,

Chris

Link to comment
Share on other sites

You have to use a multi parm interface. I don't remember which nodes in Houdini already use that, that you can inspect, but you can check out Add SOP, AttribCreate SOP to see some examples. These are compiled so you can't replicate them easily. I am sure there are HDAs that use this feature around :)

Or depending on your needs, you can also allow people to type values the way the Curve SOP does, and/or wrangle the data yourself using python before passing it to Curve SOP.

Link to comment
Share on other sites

HA!, thanks a lot magneto... perfect advice :)

You just need to create a folder and set it to "Multiparm Block (list)". Then simply add the parameter input fields you need as sub-tree.

Thanks!

EDIT: it makes me sad that I couldn't figure that out by myself and had to create a topic for it :(

Edited by chiess
Link to comment
Share on other sites

Thanks magneto!

I have another question which you (or anyone really) probably know the answer.

What is the syntax for dynamic channel referencing? I couldn't find a real answer online so far.

For example:

I have a parameter field which is called cpt1x, another one which is called cpt2x, etc.

I know have a constant in a vopsop which references those parameters, like ch("../cpt1x").

The problem I have now, is that the 1 in the ch() should by dynamic, such as ch("../cpt" + attribute + "x")

I don't really know what the correct syntax could be in Houdini to achieve that?

Thanks,

Chris

Edited by chiess
Link to comment
Share on other sites

Do you mean like this as expression in a constant inputfield ?

ch(sprintf("../../cpt%dx", randomAttrib))

Not working, so I guess not :)

Can you show me a quick example please, that would be great.

Thanks magneto

EDIT: Hmm, it looks like I have to use a VEX node and write a short line of code somehow in there. (never used the VEX node before, no idea how it works yet, but very curious). It seems to give me a lot more power overall, or is that wrong?

Edited by chiess
Link to comment
Share on other sites

No you have to do it all in VEX. You can also use expressions but this is more direct and probably faster. So create an AttribWrangle and paste this:


string name = sprintf("p%s", 1);
vector v = chv(name);
printf("%s\n", v);[/CODE]

It should print the value of the parameter whose name you built using sprintf. In my case it's p1. If you want the parameter one level up, then use "../p%s".

Link to comment
Share on other sites

Thanks anim!

It worked nicely. It is weird though that it only takes strings as possibility to connect them with each other. A quick function ala str(xxx) would have helped a lot in such cases. But I guess, that is why you have the option to use VEX like magneto said.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...