Jump to content

Valid groups rename


Alexey Vanzhula

Recommended Posts

My node have 2 input geometries with groups:

  • #1: group1, group2
  • #2: group1

I need to auto rename groups from #2 geometry with valid index.

So in this example i need:

  • #1: group1, group2
  • #2: group3

Numbers in names of all groups (#1, #2) have to be considered.

Edited by Alexey Vanzhula
Link to comment
Share on other sites

This depends on what you know about the group names and the amount of groups.

if you know input_1 always has 2 groups and input_2 always has 1 group. you can simply use a group node to rename group 1 to group 3 of input_2.

I guess this is not the case, so if you do not know the amount of groups of either input for sure, there are many ways to go by.

Since the string editing in Houdini is not its strong point, I would suggest, instead of using groups, to use an integer attribute (point or primitive depending on what you want to group)

if you have groups and want to assign these attributes, you can use a simple foreach node with group* set as its group and use a attribute create with the index stamp value (stamp("../","FORIDXVALUE",0)) by default.

after that you could use an attribute promote to check the maximum value of this attribute of input_1 by promoting it to a detail value and setting it to maximum. Then you can shift the attribute of input_2 by this value:($GRPINT+detail("../attribpromote1","GrpInt",0)) something like that.

finally you can then use a partition sop to go create groups, make the rule line something like: group$GRPINT

There must be more ways to do this, possibly using the primgrouplist / pointgrouplist expressions.

I hope that helps ;)

Edited by acey195
Link to comment
Share on other sites

You can also rename groups by using a group node. The name of the new group needs to be correct and then you can just put the old/wrong group name as the selection criteria and then delete the old group. There is also a rename option in the group node, but the issue that it has is that it can't overwrite existing groups (so if you need to order a list of groups it can have issues, but for your purposes it might be fine).

So what you could do is this: have a group node on your #2 geometry before the merge and give the name of that group this expression:

group_`argc(pointgrouplist("../last_node_of_#1_geometry_before_merge"))+1`

And then put "group_1" in the selection criteria (so it selects the same things as there are in "group_1") and then delete "group_1" (I'm going to assume you know how to do that).

Do note that this only works if geometry #2 has only 1 group and the name of that group is always "group_1". If that is the case you might also be able to replace the name with that expression in the node where you originally create "group_1" (instead of having a group node to rename "group_1" just give it the right name when it's created).

I hope it's understandable what I'm writing here and I hope it helps you. Either way, good luck with it ;)

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