Jump to content
cakeray

Multiparm list to set point attribute values - python help?

Recommended Posts

cakeray    0

Hello all,

I'm currently working on a digital asset that creates sections from a given model. Each of these sections will have different values for different sections (the attribute values of all points within a section remain the same). Since the number of sections can vary, I've decided to go with the multiparm list to handle input.

Since I've never used the multiparm before, I'm not sure how I can use these values within the HDA. From what I've been able to find here and on odforce, python seems like a good way to go. I've never used python in houdini so I'm a bit lost. How would I use python to accept the user values and set it for the points of the corresponding sections?

Any help or leads will be extremely helpful.

Pictures attached.

Thanks,
Rushil

Capture.JPG

Capture2.JPG

Edited by cakeray

Share this post


Link to post
Share on other sites
trzanko    41

if you hover over the name to the left of the text box for inputting values you will see that the names are uniqued. in a multiparm it would be something like attrib0, attrib1, attrib2

To access this data by groups you can do some string manipulation in vex. you don't necessarily need python for this. for example you can do something like this:

@pointAttrib = ch("attrib"+itoa(@ptnum));

if you want unique attribs on the points such that each point has attrib0, attrib1, .... attribN you'll have to do a bit of python but what's nice is that you can create a python script to populate a wrangle with code. 

To start you'll have to set up a  script that cooks every time you click on the multiparm add/subtract, you  can do this in the edit parm interface area and set up the multiparm with a callback script. You can write scripts in the script tab of the interface. 

Your script can look something like this:

node = hou.node("/obj/geo1/attribwrangle1/")

numAttribs = node.parm("numMultiParms").eval()

snippetCode = ""

for i in range(0,numAttribs,1):
	snippetCode += "\n" + "float attribName" + str(i) + " = " + 'ch("attrib"' + str(i) + ");" 

node.parm("snippet").set(snippetCode)

That'll work but you'll definitely want to make it so that you just add to the existing code that's in the snippet or else you'll overwrite it every time unless you set it in python lol it's easy to do just read what's already there into a string, save the code you want to save and then add this stuff. Will probably also want to add some logic to only put a new line when the iteration is > 1 but I'll leave that to you! 

Hope this helps

Tighe

 

Edited by trzanko

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

×