Jump to content

How to create dyanmic HDA parameters based on attributes.


Latimerias

Recommended Posts

Hello,

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
Link to comment
Share on other sites

  • 2 weeks later...

@carthick

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
Link to comment
Share on other sites

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

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
node.parm("multiparm").set(len(types))

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

lil_demo.thumb.gif.b5a950d09ee2df2df09efdcf119b69a3.gif

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
Link to comment
Share on other sites

@Alain2131

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!

Edit:

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. 

EDIT 2

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