Jump to content

Multiparm to perform action on each pieces (or groups)


Recommended Posts

I'm working on an asset and I want to let the user perform different action individually on each pieces but instead of creating all the node for each pieces I would like to use a Multiparm for that. I'm really struggling to find a solution and I would really appreciate some help ! 

I'm attaching an simplify example to let you know more detailed what I want to do.
Thank you

odforce_multiparm.png

odforce_multiparm.hipnc

Link to comment
Share on other sites

You need to use a foreach loop to iterate over your nodes. The add sop is a different case as it is a basic for loop. Where as you want to iterate over select items. 

As of note, avoid using groups to manipulate data like this. Since Foreach's no longer take groups as input it is best to handle them with attributes. Especially in consideration of the common name attribute, you save a lot of data overhead as opposed to having multiple groups to do the same work. Groups only represent Boolean data. They are either in or out. Unless in the case you have overlaps, but even then you should default to name first then groups for secondary sources.

I have encapsulated the example in a subnet for a better real world example i.e. eventual use in an hda. On the subnet is the multiparm block. I split out the groups you want to work with first and bypass the rest. The multiparm list number is channel references to the max number of items in the list. Then I foreach loop on each name attribute. In a for loop like add sop you can just channel reference the multiparm number into the iteration of a for loop. Here you need to ne a bit tricky and take into account eh foreach loop will go inorder of the list of items. In order to make the user aware of what item they are rotating I made a label that indexs into the list items of the name attribute so you can identify which item is being manipulated.

For additional help look at how I modified the channel references from the multiparm block to the parameters in the for loop. You need to edit the channel references so the # in the interface is the equivalent of the loop iteration in the for loop.

 

 

 

ForLoopNameMultiparm.hip

  • Like 1
Link to comment
Share on other sites

I did notice some cook lag. You can do a callback in the group menu to update the drop down.

You might be best off putting a button next to the multiparm list that will update when the user presses it. Avoid the issues where a bad cook will wipe out your settings. I would have to grab my example of it. It's a line of python or two. Sleeping baby wins this round.

Link to comment
Share on other sites

Thank's for your answer. I have to admit that I have absolutely no knowledge in python and I've never used callback... I don't use any group in my multiparm,t I just let all the pieces come in the forloop. I just want to display the same number of tabs as pieces. Like for exemple if their is 4 pieces coming I would like to display 4 tabs !

Link to comment
Share on other sites

So in this example press the reload button and it will populate the number of tabs. This will help it from being autoset every time your values upstream change. You should avoid having the system inadvertently wiping previous set values in the multi-parms.

 

This code is in the call back script. It looks for the name attribute information on the geometry of the node iterPython. Based on that if finds the length of the list. It then will set it to the multiparm.

node = hou.node('iterPython'); geo  = node.geometry();  attr = geo.findPrimAttrib('name');  list = attr.strings();  iter = str(len(list));  hou.parm('extrude').set(iter)

 

ForLoopNameMultiparm_02.hip

  • Like 1
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...