Jump to content
Sign in to follow this  

How to create dyanmic HDA parameters based on attributes.

Recommended Posts

Posted (edited)


So i import data with varying attribute values. For example ill call it attribute "Type" with string values "B,F,C,D". The attribute always imports under the name type but the values change, im looking for a way to generate a color parameter for each value so i can color value "F" primitives a different color than "B,C,D". The problem i cant get around is if the next dataset i import has values "X,A,S" how can i make the interface dynamic so that now i only have color parameters for the X,A,S values. The closest thing i can find is multiparam blocks but those would require me to manually create the parameters where instead i want parameters to generate based on the number of attribute values. Is this even possible without python, i have no experience coding.

I hope this made sense, thankyou for your time!

Edited by Latimerias

Share this post

Link to post
Share on other sites

if i understood you correctly.. i have mocked up a file for you. you dont need an otl..


hope this is what you wanted / had in mind.





Share this post

Link to post
Share on other sites
Posted (edited)


Sorry it was hard to explain, i know how to color my existing attributed what im looking for a is a way to turn them into parameters for an HDA. I need a procedural way so that when the dataset changes it generates new parameters.

Edited by Latimerias

Share this post

Link to post
Share on other sites
Posted (edited)

Okay, here's what I understand, and I got some questions.

On different datasets, you got a string attribute named "type" with different values.

Let's say you import once.
The tool auto populates B F C D.
You now have a multiparm or whatever that you can control the color and whatnot as you want.

But now, you import again, and now you got F X A S
F is still there, but X A and S are new.
What do you expect to happen then ?
The easiest to do is on each new import, wipe the entire UI and start from scratch
But this means that for different datasets, if you got the same value, you'll have to re-enter the parameter manually.

Here is a mockup, where when you import a new dataset, it resets all parms and populate with default ones.

Basically, with a button, it reads the unique values of the attribute "type" (this info was fetched from within VEX into the types detail attribute) and sets the multiparm to the amount of unique values in the attribute.

node = hou.pwd()

geo = hou.node("./OUT_script").geometry() # After the attribute wrangle fetching the unique values of the type attribute
types = geo.stringListAttribValue("types")

node.parm("multiparm").set(0) # Reset multiparm

# Set Name Parameter
for i, type in enumerate(types):
    parm = hou.parm("name_" + str(i+1)) # parm starts at 1, not 0


A few clarifications and details
I input the data by wiring it, but this can be adapted to an input from a file.
You said your data was on the prims, this is doable as well.

If you want the values of the parameters from previous datasets to remain, I see two options.
1 - Instead of wiping the multiparm each time, we go through the current parameters, look if we got any new ones, and create only the missing ones.
2 - Have a file somewhere on disk containing the relevant values for the parameters, and after resetting the multiparm, auto-fill the parameters using those values. I think this will be harder to do, though.

Edited by Alain2131
  • Like 1
  • Thanks 1

Share this post

Link to post
Share on other sites
Posted (edited)


You just made my month! To clarify i do not need the values from previous datasets to remain, the file you shared answers all my questions!! Im gonna need to do some changes to implement it for my use but it looks amazing from what i just looked at. thanks so much!


Just finished implementing it, and it works like a charm but now im trying to use material instead of color which ive having touble implementing, do you have any suggestions?  So far everything i tried assigning a material to values by reversing the blast selection so it only leaves 1 value for each iteration and then assigning a material node after that references the material specified by the parameter. the problem is i keep getting an error "bad parameter reference" when im using the same conventions. I attached a file showing what im explaining. 


Just got the material setup working! ill attach a file for anyone who looks at this in the future.





dyanmic UI with materials on prims.hipnc

Edited by Latimerias

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this