Jump to content

Sorting and Remapping Attributes


Recommended Posts

Hey,

I have the following issue. I have an ID attribtues wich looks following: 0,0,0,1,1,344,344,344,344,999,999

Now I want  increase by one, like so: 0,0,0,1,1,1,2,2,2,3,3,3

I tried a lot i.e.  partition sop, loopings with vex...but no success. Does anyone have an idea?

 

thanks. tom

 

Link to comment
Share on other sites

I had a go with python..and for good measure, I sabotaged the nicely ordered ID sequence by randomizing the order 0,0,0,1,1,344,344,344,344,999,999.

beside needing an extra partition node, the python code is actually quite succinct.
 

node = hou.pwd()
geo = node.geometry()

i = 0
for group in geo.pointGroups(): # loop for each group
    for point in group.points():
        point.setAttribValue("id",i) # reset id to sequential counter
    i += 1

 

sort_id_python.hipnc

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