Jump to content

simple points iteration


mutlu

Recommended Posts

Hi guys,

I am a newbie, and I have a problem (duh :D )

I got 2 connections to my attribute wrangler, both have id attribute, and I am trying to match the id attributes and then if yes, I will transfer the @P

I am writing something like this but I just can't iterate between all the points.

 

foreach(all the points in @OpInput1)
{
    foreach(all the points in @OpInput2)
    {
        if (@id == point(@OpInput2,"id",@ptnum))
        {
            @P = point(@OpInput2,"P",@ptnum);
        }
    }
}

I am sure it is so simple but like I said, I am learning :)

Thanks so much!

Link to comment
Share on other sites

int match = findattribval(1, "point", "id", @id);

if(match!=-1) @P = point(1, "P", match);

use the findattribval function it does exactly that ;)

it returns the first point number with the corresponding value and -1 if it doesn't find it

Edited by holycause
  • Like 1
Link to comment
Share on other sites

Worked like a charm my friend. Thank you. :)

Still, I also like to learn an easy way to iterate between all the points... something like foreach(all the points in @OpInput1)

Also, can i ask one more thing?
How can I sort ptnum according to id attribute? (you know ptnums change but attribute stays the same, I used blast on a geo and parted to multiple pieces, and now getting all back together, and I want them to have the old exact ptnum, which id attribute holds)

Thanks!

Link to comment
Share on other sites

8 hours ago, mutlu said:

Still, I also like to learn an easy way to iterate between all the points... something like foreach(all the points in @OpInput1)

If you set the wrangle node to "point", it will of course do this implicitly otherwise I think  " for(int pt_num = 0; pt_num < npoints(0); ++pt_num) " is the only way.

 

8 hours ago, mutlu said:

How can I sort ptnum according to id attribute?

You can use a sort sop set to attribute to do this, however it will only order the points, if you remove any points you won't be able to restore the point numbers as you can't have missing point numbers.  

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