F10 Posted April 6, 2020 Share Posted April 6, 2020 Hi everyone, I have a small problem I can't figure out. I can't find a clear answer online: I have different group on different points, I want to find the point using nearpoint() function, it's clear in the documentation how to look into a group of points : int nearpoint(<geometry>geometry, string ptgroup, vector pt) but how would you go about looking for points excluded from this group, keeping in mind the groups are created according to the @id of the original point so I can't pinpoint and exact group name. It as to exclude the group of the point behind processed. here is what I have for now : string grp = 'grp_' + itoa(i@id); setpointgroup(0, grp, @ptnum, 1); i@nearpt = nearpoint(1, grp, @P); that will select the point within the processed point's group how to find points excluding all points from this group? thanks a lot! Quote Link to comment Share on other sites More sharing options...
anim Posted April 6, 2020 Share Posted April 6, 2020 like in any other group parameter if group name is 'grp_0' then not that group would be '!grp_0' however it would be inefficient o be creating groups per point, since you can use point numbers directly for a group, '0' and '!0' also if you just want to always exclude current point, then instead of using groups it's better to just find closest 2 point using nearpoints() and then remove first from the array, but again it depends on what you are doing I may be just assuming stuff based on example Quote Link to comment Share on other sites More sharing options...
F10 Posted April 6, 2020 Author Share Posted April 6, 2020 17 minutes ago, anim said: like in any other group parameter if group name is 'grp_0' then not that group would be '!grp_0' however it would be inefficient o be creating groups per point, since you can use point numbers directly for a group, '0' and '!0' also if you just want to always exclude current point, then instead of using groups it's better to just find closest 2 point using nearpoints() and then remove first from the array, but again it depends on what you are doing I may be just assuming stuff based on example Thanks Tomas, I see, it works, but the issue I have with this solution is that the group number is different according to each point so I'd need a way to change the group number in the string in the nearpoint function. Here is a screengrab of the situation: in short I have a slover moving points according to a vector. Each point is creating a line, I'm grouping the points per line. When a line interesct, it's getting the vector of the intersected point from the other group and change direction accordingly. On the screen grab, point 76 from grp_2 is intersecting with the other line. I'm getting a correct result from your solution pointing 'grp_2' in the nearpoints() function. Is there a way to make the group number in this string procedural according to the processed point? ---->something like '!grp_@id' ??? maybe Yup, I did the nearpoints array removing the 1st point, it does work. Florian Quote Link to comment Share on other sites More sharing options...
anim Posted April 6, 2020 Share Posted April 6, 2020 (edited) 6 minutes ago, F10 said: Is there a way to make the group number in this string procedural according to the processed point? ---->something like '!grp_@id' ??? maybe yes, exactly as you had it, just combine with the ! as mentioned to negate the group string grp = '!grp_' + itoa(i@id); Edited April 6, 2020 by anim Quote Link to comment Share on other sites More sharing options...
F10 Posted April 6, 2020 Author Share Posted April 6, 2020 (edited) 44 minutes ago, anim said: yes, exactly as you had it, just combine with the ! as mentioned to negate the group string grp = '!grp_' + itoa(i@id); Actually, that didn't give the excepted result. Adding '!grp_' to the string kills all the groups as per this screenshot : This options works better but somehow the point 70, 3rd on the array is from the same group as pt 76 and is showing in the selected points. it's pretty close tho. Edited April 6, 2020 by F10 Quote Link to comment Share on other sites More sharing options...
anim Posted April 6, 2020 Share Posted April 6, 2020 You can't set those groups in the same wrangle as nearpoint is looking at the input geo, the groups have to exist on the input geo so split it in 2 Also when you are setting the group don't use ! in it's name, that's just to negate the matching pattern Quote Link to comment Share on other sites More sharing options...
F10 Posted April 6, 2020 Author Share Posted April 6, 2020 6 hours ago, anim said: You can't set those groups in the same wrangle as nearpoint is looking at the input geo, the groups have to exist on the input geo so split it in 2 Also when you are setting the group don't use ! in it's name, that's just to negate the matching pattern Hey Tomas, I'm not getting much luck on this. It's still getting points from the same group in the array. I guess I'm missing something obvious, if you have 5mn, I've attached the hip file...! Thanks a lot Florian VEXgrp_01.hiplc Quote Link to comment Share on other sites More sharing options...
anim Posted April 6, 2020 Share Posted April 6, 2020 in find_nearpoints replace this i[]@nearpts = nearpoints(1, "!grp", @P, .1, 4); with this string grp = "!grp" + itoa(i@source); i[]@nearpts = nearpoints(1, grp, @P, .1, 4); or alternatively you can completely bypass your set_lines_grp as you don't need to have those groups, because you can use ad-hoc group syntax in nearpoints directly: string grp = "@source!=" + itoa(i@source); i[]@nearpts = nearpoints(1, grp, @P, .1, 4); VEXgrp_01_fix.hiplc 1 Quote Link to comment Share on other sites More sharing options...
F10 Posted April 6, 2020 Author Share Posted April 6, 2020 19 minutes ago, anim said: in find_nearpoints replace this i[]@nearpts = nearpoints(1, "!grp", @P, .1, 4); with this string grp = "!grp" + itoa(i@source); i[]@nearpts = nearpoints(1, grp, @P, .1, 4); or alternatively you can completely bypass your set_lines_grp as you don't need to have those groups, because you can use ad-hoc group syntax in nearpoints directly: string grp = "@source!=" + itoa(i@source); i[]@nearpts = nearpoints(1, grp, @P, .1, 4); VEXgrp_01_fix.hiplc A big thanks to you Tomas, That does to trick nicely indeed. Keep safe! 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.