Jump to content

Multiparm list to set point attribute values - python help?


cakeray

Recommended Posts

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

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