domsewell Posted September 4, 2019 Share Posted September 4, 2019 Hi guys, Im a little stumped on a vex issue im having whilst trying to utilize the nearpoints function when building an array. The idea is that i have multiple curves, each with different colour values, which i group the end points of and then run a function which gathers all the nearest points to each of these endpoints and assigns them to an array. (this is currently working as can be seen in my spreadsheet.) However, i then wish to take this array that has been created for each of the endpoints and run an if statement through it that says if the points in the array have a different colour value to the end point they belong to then add them to a group. Im then hoping to perform a nearpoint function using this group as a filter to get the nearest point that belongs to any curve other than itself. Im unfortunately having an issue with this if statement as it seems to only output points 0-9 regardless of the previous rules set in the code. Help is really appreciated as im truly stumped on this one. Thanks in advance guys! Nearest_Points_Array_Problem.hip Quote Link to comment Share on other sites More sharing options...
Atom Posted September 4, 2019 Share Posted September 4, 2019 I wonder if VEX is failing on the setpointgroup, because you have two different styles of quotes? Try double quoting set. Quote Link to comment Share on other sites More sharing options...
domsewell Posted September 5, 2019 Author Share Posted September 5, 2019 @Atom sadly that doesn't seem to have changed my result at all. if you are able to take a look at the project file id much appreciate it. Cheers, Dom Quote Link to comment Share on other sites More sharing options...
Atom Posted September 5, 2019 Share Posted September 5, 2019 (edited) I have found that the exact comparison between two float values in Houdini can sometimes fail. Try revising your detection IF statement to be more of a threshold, or close to the mark type of detection. float threshold = 0.04; //ch("threshold") or add slider. if(abs(APC-@Cd.x) > threshold ) { //Different. } else { // Close enough. } Edited September 5, 2019 by Atom Quote Link to comment Share on other sites More sharing options...
domsewell Posted September 6, 2019 Author Share Posted September 6, 2019 Hi @Atom Thank you so much for looking in to this for me i was aware that float precision may have been an issue, this didn't seem to be the fix however. The good news is that the code now works as intended by switching out the for each loop for a regular for loop Thanks again i appreciate it! 1 Quote Link to comment Share on other sites More sharing options...
anim Posted September 6, 2019 Share Posted September 6, 2019 On 9/4/2019 at 11:45 AM, domsewell said: Im unfortunately having an issue with this if statement as it seems to only output points 0-9 regardless of the previous rules set in the code. 8 minutes ago, domsewell said: The good news is that the code now works as intended by switching out the for each loop for a regular for loop its because with foreach loop, num already contained point number and not index, so when you used nPs[num] in your setpointgroup(), it was only going to return something for points 0-9 as your nPs was max 10 points, so in your original code you can try using num directly 2 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.