Javier31 Posted September 1, 2017 Share Posted September 1, 2017 Hello everyone, Hopefully, someone can help me with this one :-) I do have a bunch of particles flying upwards and creating a trail of points behind them that i connect as polylines with the trail SOP. (see attached image) Then i scatter some points on these lines. These new points inherit the id of the original particle and what i would like to to do is to use these id's to control a nearpoints function in order to connect with the nearest points except with the points that have the same id (basically i want to connect with those points that are not in the same line as the point that searches i attach a file and an screenshot of what i have so far Any help would be really appreciated! cheers!! connecting just to other lines.hipnc Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 ? foreach(int ele; nearpoints(0,@P,5)){ if(point(0, "id", ele) != @id){ int line = addprim(0,"polyline"); addvertex(0,line,@ptnum); addvertex(0,line,ele); } } Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 ? foreach(int ele; nearpoints(0,@P,5)){ if(point(0, "id", ele) != @id){ int line = addprim(0,"polyline"); addvertex(0,line,@ptnum); addvertex(0,line,ele); } } Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 ? foreach(int ele; nearpoints(0,@P,5)){ if(point(0, "id", ele) != @id){ int line = addprim(0,"polyline"); addvertex(0,line,@ptnum); addvertex(0,line,ele); } } Quote Link to comment Share on other sites More sharing options...
Javier31 Posted September 1, 2017 Author Share Posted September 1, 2017 (edited) Thanks a lot but I'm sorry i completely forgot to mention that i don't want to include in the "search" for nearest points those with same id neither if not I will always have points finding many points that have the same id and not creating any connection at all unless i increase the total amount of point to search - something I would like to keep low as 2 or 3 max per point Basically, every single point should be able to make 2 or 3 connections max with points of different id :-) cheers! Edited September 1, 2017 by Javier31 Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 Add pointwrangle after popnet setpointgroup(0, sprintf("pg%d", @ptnum), @ptnum, 1); i@gr = @ptnum; chenge attribwrangle2 to int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3); foreach(int ele; nps){ int line = addprim(0,"polyline"); addvertex(0,line,@ptnum); addvertex(0,line,ele); } Sorry can't upload the file, odforce.... Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 (edited) Add pointwrangle after popnet setpointgroup(0, sprintf("pg%d", @ptnum), @ptnum, 1); i@gr = @ptnum; chenge attribwrangle2 to int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3); foreach(int ele; nps){ int line = addprim(0,"polyline"); addvertex(0,line,@ptnum); addvertex(0,line,ele); } Sorry can't upload the file, odforce.... connecting just to other lines_v02.hipnc Edited September 1, 2017 by fencer Quote Link to comment Share on other sites More sharing options...
Javier31 Posted September 1, 2017 Author Share Posted September 1, 2017 Oh man this is amazing many thanks! :-) Do you mind if i ask you about this line? // int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3); i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit? ALso.. what does "* ^pg%d" mean? Apologise for my ignorance.. really! :-) Many thanks Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 1 hour ago, Javier31 said: Oh man this is amazing many thanks! :-) Do you mind if i ask you about this line? // int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3); i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit? ALso.. what does "* ^pg%d" mean? Apologise for my ignorance.. really! :-) Many thanks int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist, int maxpts) ptgroup - group mask * - all, ^ - except result will be all point except in group (pg0 or pg1 or pg2...) sprintf("* ^pg%d", @gr) http://www.cplusplus.com/reference/cstdio/sprintf/ pg-symbols, %d - argument in your case %d = @gr = id of line Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 1 hour ago, Javier31 said: Oh man this is amazing many thanks! :-) Do you mind if i ask you about this line? // int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3); i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit? ALso.. what does "* ^pg%d" mean? Apologise for my ignorance.. really! :-) Many thanks int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist, int maxpts) ptgroup - group mask * - all, ^ - except result will be all point except in group (pg0 or pg1 or pg2...) Quote Link to comment Share on other sites More sharing options...
fencer Posted September 1, 2017 Share Posted September 1, 2017 1 hour ago, Javier31 said: Oh man this is amazing many thanks! :-) Do you mind if i ask you about this line? // int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3); i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit? ALso.. what does "* ^pg%d" mean? Apologise for my ignorance.. really! :-) Many thanks int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist, int maxpts) ptgroup - group mask * - all, ^ - except result will be all point except in group (pg0 or pg1 or pg2...) 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.