bjs 0 Posted August 1, 2016 Hello – after quite a bit of searching and a pretty long struggle I've decided to post my simple question concerning the "nearpoints" function (http://www.sidefx.com/docs/houdini15.5/vex/functions/nearpoints) that I am using on a Point Wrangle SOP. The manual states that, under "ptgroup", one can specify a "point group pattern to limit the search to": int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist) While inputting a simple pattern like "0 11 18" works (limiting the "nearpoints" function to these points like it's supposed to), I can't get it to work when I put in the sample expression "@Cd.x>0.5". Has anyone ever used the "ptgroup" argument with an expression, because all the examples I found always only used GEOHANDLE + POSITION + MAXDIST with an optional MAXPTS at the end? Here's the code on the Point Wrangle SOP that works: int nearest[] = nearpoints(0, "0 11 18", @P, 1); i@found = len(nearest); i@first = nearest[1]; This one doesn't, giving me a wrong result and a green "implicit cast from vector to float" error: int nearest[] = nearpoints(0, @Cd<1.0, @P, 1); i@found = len(nearest); i@first = nearest[1]; I am afraid it is a very beginner's mistake, so I am grateful for any answers! Thanks, Bastian. Share this post Link to post Share on other sites
animatrix 294 Posted August 1, 2016 It should be: "Cd<1.0" Share this post Link to post Share on other sites
rayman 458 Posted August 1, 2016 (edited) One workaround I found is to create detail string attribute called for example "at" with value set to "@"; Then in wrangle node you can use detail(0,"at") to return @ as string without messing with the attributes. In your case : string grp = detail(0,"at")+"Cd<1.0"; int nearest[] = nearpoints(0, grp, @P, 1); I usually use it to check for closest pieces different from current one: string grp = detail(0,"at")+"name!="+s@name; int near = nearpoint(0,grp,v@P); If it works without @, like Yunus said, then silly me D: Edited August 1, 2016 by rayman Share this post Link to post Share on other sites
bjs 0 Posted August 2, 2016 Thanks to both of you! Due to the time difference I could only now check your answers. Yunus, as suggested, I simply omitted the "@" and put the expression in quotation marks: int nearest[] = nearpoints(0, "Cd.x<1.0", v@P, 1); i@found = len(nearest); i@first = nearest[1]; While I don't get an error, this doesn't yield any result either. I attached a screenshot to illustrate the setup. Share this post Link to post Share on other sites
bjs 0 Posted August 2, 2016 Same result with your proposed solution, Pavel – no error, but not the intended result: string ptgroup = detail(0,"at")+"Cd.x<1.0"; int nearest[] = nearpoints(0, ptgroup, v@P, 1); i@found = len(nearest); i@first = nearest[1]; Added the screenshot as well. Shouldn't there now also be a detail attribute on the geometry (lower pane), or am I missing something? Share this post Link to post Share on other sites
bjs 0 Posted August 2, 2016 I am also wondering if it's the smartest way of filtering the result? Of course, another option would be to get all the nearest points and filter afterwards. But I thought since the manual explicitly states the option to do so, it would be a really smart and efficient way to do it: int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist) ptgroup: A point group pattern to limit the search to. Can be a SOP-style group pattern such as 0-10 or@Cd.x>0.5. An empty string will match all points. Share this post Link to post Share on other sites
f1480187 797 Posted August 2, 2016 (edited) Try unicode representation of the @ character: "\x40Cd.x<1.0". Snippet parser substitutes any "@" character with string "_bound_", it does not check if the symbol resides inside string. If you dive inside asset you may see this string by looking inside Attribute VOP's generated VEX code: "_bound_Cd.x<1.0". That's why Pavel's method works: expression passed to the compiler unchanged. You should have created detail attribute using Attribute Create node. BTW, the very first element in an array is [0], not [1]. Of course, if you don't usually call it "zeroth element". Edited August 2, 2016 by f1480187 2 Share this post Link to post Share on other sites
bjs 0 Posted August 3, 2016 Sorry for not reporting back sooner ... I masked the "@" character, as F1 suggested, and it worked perfectly! Thanks to everyone for their help! Added the screenshot for future reference ... Share this post Link to post Share on other sites
3dome 136 Posted August 3, 2016 (edited) interesting, since the help suggests using @Cd.x>0.5 is this just an error in the docs? Edited August 3, 2016 by 3dome Share this post Link to post Share on other sites
bjs 0 Posted August 3, 2016 Exactly this was driving me crazy. The help fails to mention that the "@" character must be masked, as suggested by F1 ... Share this post Link to post Share on other sites
bjs 0 Posted August 3, 2016 (edited) Since it was originally my goal to limit the nearpoints() function to an exisiting point group, it might be worth to mention that Moritz pointed out to me how that is done successfully (see screenshot for this). Note that activeGroup is the name of the existing point group ... Edited August 3, 2016 by bjs Share this post Link to post Share on other sites
anim 1,263 Posted May 21, 2020 3 hours ago, Elon said: Is this fixed now? it should work fine Share this post Link to post Share on other sites
haroon alhitary 0 Posted January 19, 2021 (edited) On 8/1/2016 at 9:24 PM, bjs said: Hello – after quite a bit of searching and a pretty long struggle I've decided to post my simple question concerning the "nearpoints" function (http://www.sidefx.com/docs/houdini15.5/vex/functions/nearpoints) that I am using on a Point Wrangle SOP. The manual states that, under "ptgroup", one can specify a "point group pattern to limit the search to": int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist) While inputting a simple pattern like "0 11 18" works (limiting the "nearpoints" function to these points like it's supposed to), I can't get it to work when I put in the sample expression "@Cd.x>0.5". Has anyone ever used the "ptgroup" argument with an expression, because all the examples I found always only used GEOHANDLE + POSITION + MAXDIST with an optional MAXPTS at the end? Here's the code on the Point Wrangle SOP that works: int nearest[] = nearpoints(0, "0 11 18", @P, 1); i@found = len(nearest); i@first = nearest[1]; This one doesn't, giving me a wrong result and a green "implicit cast from vector to float" error: int nearest[] = nearpoints(0, @Cd<1.0, @P, 1); i@found = len(nearest); i@first = nearest[1]; I am afraid it is a very beginner's mistake, so I am grateful for any answers! Thanks, Bastian. I know its an old post but for those who still face the same problem here is what works for me. Simply write the expression without spaces as if it was written on a SOP node. i[]@pts; pts = nearpoints(0, "@Cd.x>0.8", @P,20); Hope this helps others Edited January 19, 2021 by haroon alhitary Share this post Link to post Share on other sites