mutlu Posted September 15, 2016 Share Posted September 15, 2016 Hi guys, I am a newbie, and I have a problem (duh ) 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! Quote Link to comment Share on other sites More sharing options...
holycause Posted September 15, 2016 Share Posted September 15, 2016 (edited) 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 September 15, 2016 by holycause 1 Quote Link to comment Share on other sites More sharing options...
mutlu Posted September 16, 2016 Author Share Posted September 16, 2016 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! Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted September 16, 2016 Share Posted September 16, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
mutlu Posted September 17, 2016 Author Share Posted September 17, 2016 Thank you Tom, sort sop works like a charm! I have seen that in another topic and already used it: sort sop, point sort: by attribute, attribute: id regards Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted September 18, 2016 Share Posted September 18, 2016 No problem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.