ParticleSkull Posted September 14, 2018 Share Posted September 14, 2018 Hey guys, is there a way to select points with one edge connection only? thx Quote Link to comment Share on other sites More sharing options...
toadstorm Posted September 14, 2018 Share Posted September 14, 2018 there's probably an easier way to do this with SOPs, but in VEX: int n = neighbours(0, @ptnum); if(len(n) < 2) { @group_ends = 1; } 1 Quote Link to comment Share on other sites More sharing options...
ParticleSkull Posted September 15, 2018 Author Share Posted September 15, 2018 hey Henry, thx man it wasn't working this way but I found out that the neighbours function works if I specify the n as a array, like: int n [] = array(); n = neighbours(0 , @ptnum); if(len(n) < 2) { @group_ends = 1; } but I don't really understand it. Do you know what's going on? Quote Link to comment Share on other sites More sharing options...
vicvvsh Posted September 15, 2018 Share Posted September 15, 2018 Because neighbours function return array. Henry just forgot type square brackets after n variable. 1 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted September 15, 2018 Share Posted September 15, 2018 In a pointwrangle or a group expression SOP: neighbourcount(0, @ptnum) < 2 2 Quote Link to comment Share on other sites More sharing options...
ParticleSkull Posted September 15, 2018 Author Share Posted September 15, 2018 You're awesome guys, thank you. Victor, thx, it works if I do it like this: int n []= neighbours(0 , @ptnum); if(len(n) < 2) { @group_ends = 1; } but it's even easier the way Konstantin said if(neighbourcount(0, @ptnum) < 2) { @group_ends = 1; } Thx Konstantin Cheers, Alvaro Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted September 15, 2018 Share Posted September 15, 2018 Or just i@group_ends = neighbourcount(0, @ptnum) < 2; 1 Quote Link to comment Share on other sites More sharing options...
Atom Posted September 15, 2018 Share Posted September 15, 2018 (edited) One thing to keep in mind is that code will return both the start and end points, as requested in the first post. But if you just want the end point or start point you may need to filter for that by looping over the primitives and detecting point #0 or point # @numpt. // @ptnum is zero based. if (@ptnum==(@numpt-1)){i@group_ends=1;} Edited September 15, 2018 by Atom Quote Link to comment Share on other sites More sharing options...
anim Posted September 15, 2018 Share Posted September 15, 2018 On 9/15/2018 at 2:38 PM, Atom said: One thing to keep in mind is that code will return both the start and end points, as requested in the first post. But if you just want the end point or start point you may need to filter for that by looping over the primitives and detecting point #0 or point # @numpt. // @ptnum is zero based. if (@ptnum==(@numpt-1)){i@group_ends=1;} Expand no loops necessary and you should try to avoid them if you can also first point of the primitive doesn't guarantee that it's at the start or at the end or even that the primitive has any start or end if it's closed, so you are better off using points belonging to first or last vertex and either checking if the prim is closed or using the neighbourcount() test so to detect all you can combine first test with test whether point belongs to the first or the last vertex of the primitive int pts[] = primpoints(0, @primnum); int isend = neighbourcount(0, @ptnum) == 1; int isfirst = @ptnum == pts[0]; int islast = @ptnum == pts[-1]; i@group_ends = isend; i@group_start = isend && isfirst; i@group_end = isend && islast; OR mentioned open/closed poly test int pts[] = primpoints(0, @primnum); int isopen = !primintrinsic(0, "closed", @primnum); int isfirst = @ptnum == pts[0]; int islast = @ptnum == pts[-1]; i@group_ends = isopen && (isfirst || islast); i@group_start = isopen && isfirst; i@group_end = isopen && islast; 3 1 Quote Link to comment Share on other sites More sharing options...
Atom Posted September 15, 2018 Share Posted September 15, 2018 (edited) Thanks for the code Tomas, that is way quicker. It detects start and end points on my tree branch primitives returned from findshortestpath. Edited September 15, 2018 by Atom 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.