Masoud Posted February 23, 2019 Share Posted February 23, 2019 Hello; I would like to retrieve total number of connected primitives in my geometry, using VEX. I also want to create a group for each connected primitive. Thanks for helping. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 23, 2019 Share Posted February 23, 2019 25 minutes ago, Masoud said: retrieve total number of connected primitives i@islands = nuniqueval(0, 'prim', 'class'); 26 minutes ago, Masoud said: create a group for each connected primitive int island = prim(0, 'class', @primnum); string grp_name = 'island_' + itoa(island); setprimgroup(0, grp_name, @primnum, 1, 'set'); group_islands.hiplc 2 Quote Link to comment Share on other sites More sharing options...
Masoud Posted February 23, 2019 Author Share Posted February 23, 2019 (edited) 1 hour ago, konstantin magnus said: i@islands = nuniqueval(0, 'prim', 'class'); int island = prim(0, 'class', @primnum); string grp_name = 'island_' + itoa(island); setprimgroup(0, grp_name, @primnum, 1, 'set'); group_islands.hiplc Thank you very much... How could I iterate over connected primitives? Edited February 23, 2019 by Masoud Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 23, 2019 Share Posted February 23, 2019 4 hours ago, Masoud said: How could I iterate over connected primitives? A combination of findattribvalcount() and findattribval() will get you there: int vals = nuniqueval(0, 'prim', 'class'); for(int i = 0; i < vals; i++){ int num = findattribvalcount(0, 'prim', 'class', i); for(int j = 0; j < num; j++){ int pr = findattribval(0, 'prim', 'class', i, j); int some_value = i + j; setprimattrib(0, 'smth', pr, some_value, 'set'); } } 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.