Alexandros Papadopoulos Posted December 6, 2016 Share Posted December 6, 2016 Hello, I have this crude tree, and I want to group all ‘leaves’. The leafs are not connected to the tree, they just float around, and all of them are just these two prim squares. I can't find a way to make the grouping. I guess an expression or primitive wrangle could help, but I am a novice in these things. Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 6, 2016 Share Posted December 6, 2016 a primitive wrangle would be the solution with the pretty much the best performance yeah I guess something like this could work (typing this from the top of my head, could have typo's/errors): //// int connectedVertCount, i, pts[]; connectedVertCount = 0; pts = primpoints(0, @primnum); for(i = 0; i < @numvtx; i++) { connectedVertCount += len( pointvertices(0, pts[i])); } @group_leaves = (connectedVertCount == 5); 1 Quote Link to comment Share on other sites More sharing options...
animatrix Posted December 6, 2016 Share Posted December 6, 2016 (edited) If the vertex count is the same/similar, you can do something like this inside a Primitive Wrangle node: if ( primvertexcount ( 0, @primnum ) == 8 ) i@group_leaves = 1; EDIT: Thought it was a single polygon, disregard this answer Edited December 7, 2016 by pusat Quote Link to comment Share on other sites More sharing options...
davpe Posted December 7, 2016 Share Posted December 7, 2016 or you can use combination of Assemble SOP and Measure SOP. Assemble will make a name attribute for each polygon island which you can loop over. in the For each loop use Measure SOP and measure area of each polygon island. since all leaves will have the same area you can group them by area attribute. this is a slower method than wrangle but i'd say it will give better result in this particular case. Quote Link to comment Share on other sites More sharing options...
carlo_c Posted December 7, 2016 Share Posted December 7, 2016 I've done this exact thing for trees using the method above to measure the area, works great. Just cache out the new tree with correct groups afterwards and you won't need to worry about speed. Quote Link to comment Share on other sites More sharing options...
Alexandros Papadopoulos Posted December 7, 2016 Author Share Posted December 7, 2016 Thank you all, both the wrangle code and the measure technique worked perfectly. 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.