bjs Posted August 1, 2016 Share 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. Quote Link to comment Share on other sites More sharing options...
animatrix Posted August 1, 2016 Share Posted August 1, 2016 It should be: "Cd<1.0" Quote Link to comment Share on other sites More sharing options...
rayman Posted August 1, 2016 Share 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 Quote Link to comment Share on other sites More sharing options...
bjs Posted August 2, 2016 Author Share 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. Quote Link to comment Share on other sites More sharing options...
bjs Posted August 2, 2016 Author Share 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? Quote Link to comment Share on other sites More sharing options...
bjs Posted August 2, 2016 Author Share 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. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted August 2, 2016 Share 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 Quote Link to comment Share on other sites More sharing options...
bjs Posted August 3, 2016 Author Share 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 ... Quote Link to comment Share on other sites More sharing options...
3dome Posted August 3, 2016 Share 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 Quote Link to comment Share on other sites More sharing options...
bjs Posted August 3, 2016 Author Share 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 ... Quote Link to comment Share on other sites More sharing options...
bjs Posted August 3, 2016 Author Share 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 Quote Link to comment Share on other sites More sharing options...
Elon Posted May 21, 2020 Share Posted May 21, 2020 Is this fixed now? Quote Link to comment Share on other sites More sharing options...
anim Posted May 21, 2020 Share Posted May 21, 2020 3 hours ago, Elon said: Is this fixed now? it should work fine Quote Link to comment Share on other sites More sharing options...
haroon alhitary Posted January 19, 2021 Share 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 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.