Latimerias Posted July 22, 2021 Share Posted July 22, 2021 (edited) 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 July 22, 2021 by Latimerias Quote Link to comment Share on other sites More sharing options...
carthick Posted July 30, 2021 Share Posted July 30, 2021 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. colorByAttr.hipnc Quote Link to comment Share on other sites More sharing options...
Latimerias Posted July 30, 2021 Author Share Posted July 30, 2021 (edited) @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 July 30, 2021 by Latimerias Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted July 31, 2021 Share Posted July 31, 2021 (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. 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) 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 July 31, 2021 by Alain2131 1 1 Quote Link to comment Share on other sites More sharing options...
Latimerias Posted July 31, 2021 Author Share Posted July 31, 2021 (edited) @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 August 1, 2021 by Latimerias Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted August 1, 2021 Share Posted August 1, 2021 Hey, glad it worked out ! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.