Merging attributes

   4990   4   3
User Avatar
Member
3 posts
Joined: Feb. 2016
Offline
Hey guys,

I'm very new to houdini and today I was trying to figure out how can I merge two attributes together and rename the values accordingly.

Say at the moment I got a scene where on one branch I got 4 boxes that are numbered from 0 to 4 in an attribute ‘ninja’ and on the other side I got 8 boxes that are numbered from 0 to 8 also in a attribute called ‘ninja’.

Now when I merge those two branches together in my ‘ninja’ attribute I get box 0 to 7 and then again 0 to 4. What I want is the numbers to incrementally go up so I get the whole range of the boxes 0 to 11. Hopefully that makes sense?

I attached the sample file as well which will hopefully make things bit more clear.

Any help would be much appreciated!

Attachments:
BoxesTest.hipnc (120.8 KB)

User Avatar
Member
453 posts
Joined: Feb. 2013
Offline
First off, you will probably want to work with an open Geometry Spreadsheet to follow on what is actually happening with you attributes.
For this particular task you could create an attribute after the merge. For example with a connectivity SOP (set to primitive).
Alternatively you could do some additional processing before you merge. Merging takes into account the order of its inputs. So you could, for example, use a primitive VOP SOP or attribute wrangle SOP to add the the number of copies from the first input, to the value of ninja on the seccond input.
User Avatar
Member
3 posts
Joined: Feb. 2016
Offline
hey DASD - big thanks for your reply!

I've tried using connectivity SOP and that should do the job however there is still one issue that I can't figure out.

After using the connectivity SOP I'm getting an integer value out… is there any way to convert it to string in order to add “box” at the front and then the value? so the final result needs to be ‘'box1“, ”box2“, ”box3" etc rather then 1,2,3 (I need it this way because ’'box'' name is used down the line in another setup for masking purposes)
User Avatar
Member
1738 posts
Joined: May 2006
Offline
The assemble sop will do this for you, just change the prefix from ‘piece’ to box. Doesn't even require the connectivity sop, it'll identify the islands for you.

If you like the results of the connectivity sop, and want total control over the naming, you could use a wrangle to construct your own string attribute.

Something like

s@name = ‘box’+itoa(@class);
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
3 posts
Joined: Feb. 2016
Offline
mestela - that is exactly what I was looking for! Big thanks for the help!
  • Quick Links