shadowst17 Posted March 18, 2019 Share Posted March 18, 2019 (edited) Hi guys, I was wondering if anyone had any suggestions on faster ways to get one attribute value to change a group of other attributes with the same name attribute. The usual method suggested is to use a for each node with the promote to detail set to max or min and then promote back to point. This is incredibly slow and the bottle neck for my setup. Anyone got suggestions on alternatives that are faster with the same outcome? Edited March 19, 2019 by shadowst17 Quote Link to comment Share on other sites More sharing options...
bonsak Posted March 18, 2019 Share Posted March 18, 2019 Why do you need to use a for each for this? Quote Link to comment Share on other sites More sharing options...
shadowst17 Posted March 18, 2019 Author Share Posted March 18, 2019 Just now, bonsak said: Why do you need to use a for each for this? Seems to be the most common method for getting entire pieces when only a few points have been selected. Guess it's fine if it's a one off but I need a method that works efficiently on every frame. Quote Link to comment Share on other sites More sharing options...
bonsak Posted March 19, 2019 Share Posted March 19, 2019 If you could set an attribute up stream to identify what parts of your geo you want to operate on, you might not need to use a for each. -b Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted March 19, 2019 Share Posted March 19, 2019 do you have an example file? Quote Link to comment Share on other sites More sharing options...
shadowst17 Posted March 19, 2019 Author Share Posted March 19, 2019 (edited) 1 hour ago, bonsak said: If you could set an attribute up stream to identify what parts of your geo you want to operate on, you might not need to use a for each. -b I did think about that, I might try and have an array on each point of every other point that is in this piece. 1 hour ago, ThomasPara said: do you have an example file? Here you go, quickly cobbled it together. example.hip Edited March 19, 2019 by shadowst17 Quote Link to comment Share on other sites More sharing options...
Andrea Posted March 19, 2019 Share Posted March 19, 2019 (edited) Just use a point wrangle after "attribcreate1" with this: //list all points in the group int hit[] = expandpointgroup(0,"group1"); @Cd = {0,0,0}; //run over points that ar not in the group so @hit = 0 if(@hit == 0){ //do something for each element of the array hit[] foreach(int i; hit){ //take ID of the current element array int grp_id = point(0,"ID",i); //if the ID of the point is the same ID of this element of the array then also this point is @hit = 1; if(grp_id == @ID){ @Cd = {1,0,0}; i@hit = 1; } } } Edited March 19, 2019 by Andrea 1 Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted March 19, 2019 Share Posted March 19, 2019 //set the wrangle to run over group1 int count = findattribvalcount(0,"point","id",i@id); //find how many points that have the same id for(int i = 0;i<count;i++){ //run over the points and set the color or any attribute of your likeing int found = findattribval(0,"point","id",i@id,i); vector color = set(1,0,0); setpointattrib(0,"Cd",found,color,"set"); } example_fix.hip 1 Quote Link to comment Share on other sites More sharing options...
shadowst17 Posted March 19, 2019 Author Share Posted March 19, 2019 4 hours ago, Andrea said: Just use a point wrangle after "attribcreate1" with this: //list all points in the group int hit[] = expandpointgroup(0,"group1"); @Cd = {0,0,0}; //run over points that ar not in the group so @hit = 0 if(@hit == 0){ //do something for each element of the array hit[] foreach(int i; hit){ //take ID of the current element array int grp_id = point(0,"ID",i); //if the ID of the point is the same ID of this element of the array then also this point is @hit = 1; if(grp_id == @ID){ @Cd = {1,0,0}; i@hit = 1; } } } Just now, ThomasPara said: //set the wrangle to run over group1 int count = findattribvalcount(0,"point","id",i@id); //find how many points that have the same id for(int i = 0;i<count;i++){ //run over the points and set the color or any attribute of your likeing int found = findattribval(0,"point","id",i@id,i); vector color = set(1,0,0); setpointattrib(0,"Cd",found,color,"set"); } example_fix.hip Thanks guys these have been really helpful! Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted March 19, 2019 Share Posted March 19, 2019 just tested theese solutions, and none of them are faster than the for-each, think this needs a new iteration Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted March 19, 2019 Share Posted March 19, 2019 (edited) Heres a version thats faster than the for-each, its some more nodes to make that happen. The wrangles "minimize_search", "find_unique", "set_search", and "set_color" has a combined time of around 1 sec, while the foreach is around 13 sec. This runs over 5 mill points example_fix_02.hip Edited March 19, 2019 by ThomasPara 1 Quote Link to comment Share on other sites More sharing options...
bonsak Posted March 19, 2019 Share Posted March 19, 2019 (edited) If you set the scatter to 30000 points for example, the wrangle is twice as fast as the for each node version. -b EDIT: This was when testing the example-fix.hip Edited March 19, 2019 by bonsak Quote Link to comment Share on other sites More sharing options...
shadowst17 Posted March 19, 2019 Author Share Posted March 19, 2019 35 minutes ago, ThomasPara said: Heres a version thats faster than the for-each, its some more nodes to make that happen. The wrangles "minimize_search", "find_unique", "set_search", and "set_color" has a combined time of around 1 sec, while the foreach is around 13 sec. This runs over 5 mill points example_fix_02.hip Excellent! This is even better, thank you. Quote Link to comment Share on other sites More sharing options...
cwhite Posted March 19, 2019 Share Posted March 19, 2019 If you're using H17, there's a much easier approach that's also a lot faster than the other solutions - just turn on the Use Piece Attribute toggle on Attrib Promote example_fix_03.hip 1 3 Quote Link to comment Share on other sites More sharing options...
bonsak Posted March 20, 2019 Share Posted March 20, 2019 Hey Thats awesome @cwhite Thanks. -b Quote Link to comment Share on other sites More sharing options...
emma84850 Posted November 18, 2020 Share Posted November 18, 2020 @cwhite thank you ! 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.