Jump to content

How to make HDA/Wrangle with arbitrary number of inputs?


raincole

Recommended Posts

I'm trying to make an HDA that works like this:

  1. Accept any number of geometries as inputs.

  2. Randomly select one of the inputs by their weight attribute, and output the selected one.

For example if I connect a sphere and a cube to its inputs, and set the sphere's weights as 2 and cube's as 3. Then there is a 40% chance that it outputs a sphere, and a 60% chance for a cube.

I know how to do it with Attribute Wrangle, if the number of inputs is fixed (1~4).

But what if I want an HDA that accepts any number of inputs? If I simply create an HDA with 999 inputs, while I can connect my inputs to it, I don't know how to connect them to the Attribute Wranglge inside. Attribute Wrangle only accepts 4 inputs. And even if I use spare input parameters, the number of spare inputs is still fixed...

Is there a better way to achieve this?

Link to comment
Share on other sites

There are at least 2 ways of working this out.

1. Include a note to user to initialize weights and Merge before using your HDA, this only takes up 1 input but requires initialization.

2. Use Partition to create a class attribute for each input, then like #1, merging before plugging into HDA. Run a For Loop that iterates each class, you can use Python and multiparm to create parameters if you need to address each instance individually.

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...