Juraj Posted February 6, 2017 Share Posted February 6, 2017 Hello, I am trying to remove overlapping polygons - I want to do so by computing distance to other polygons using xyzdist(). So I want to specify primgroup which will contain all, but current primitive, so that It is not returning distance to itself. According to documentation, I should pass group string which matches general SOP syntax. So for polygon number 240, primgroup parameter should be "* ^240". When I pass this parameter to the function, it returns -1 in found primitive - no primitive found. I think that the error is causing by this primgroup parameter. If I pass for example "*", then there is also no primitive found. How can I use patterns to define group inside this function? Like 0-50, *, ... This is from the docs: The name of a primitive group or a pattern to generate a primitive group. Uses the same semantics as a SOP group, so empty strings will match all primitives. Any ideas how to make this pattern working? Juraj Quote Link to comment Share on other sites More sharing options...
Juraj Posted February 6, 2017 Author Share Posted February 6, 2017 For now I did it another way, since it is only in 2d, I achieved it with this code. int primnum = pointprims(0, @ptnum)[0]; float offset = 0.00001; float dist; int prim; vector uv; int myself = 1; dist = xyzdist(0, v@P + set(offset, 0, 0), prim, uv); if (prim != primnum) myself = 0; dist = xyzdist(0, v@P + set(-offset, 0, 0), prim, uv); if (prim != primnum) myself = 0; dist = xyzdist(0, v@P + set(0, 0, offset), prim, uv); if (prim != primnum) myself = 0; dist = xyzdist(0, v@P + set(0, 0, -offset), prim, uv); if (prim != primnum) myself = 0; if (!myself) { //v@Cd = {1,0,0}; i@inside = 1; } I then promote inside attribute to primitives (using minimum operation) and then blast primitives with inside == 1 But still curious, how to make it working with primgroup option. Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 9, 2017 Share Posted February 9, 2017 (edited) Try this syntax: dist = xyzdist(0, "!* ^240", pos, prim, uvw); Edited February 9, 2017 by f1480187 Quote Link to comment Share on other sites More sharing options...
Juraj Posted February 9, 2017 Author Share Posted February 9, 2017 Hi, thanks! It works. int prim; vector uv; int firstPt = primpoint(0, @primnum, 0); vector firstPtP = point(0, "P", firstPt); string grp = "!* ^"+itoa(@primnum); float dist = xyzdist(0, grp, firstPtP, prim, uv, 0.0000001); if (prim != -1) v@Cd = {1,0,0}; However performance is much slower then the previous way. Instant cook vs 4 seconds in this case, maybe using this primgroup parameter is not that efficient. I am still curious about this syntax !* ^240 - how would you explain it? * ^240 means: check against everything, but primitive 240 ! means inversion, like in blast sop: delete non selected, so wouldnt it negate the * symbol? Like that: !* == (nothing) However, if I leave out !*, then it doesn't work. Hmm... Quote Link to comment Share on other sites More sharing options...
anim Posted February 12, 2017 Share Posted February 12, 2017 (edited) On 2/9/2017 at 8:07 AM, Juraj said: ... I am still curious about this syntax !* ^240 - how would you explain it? * ^240 means: check against everything, but primitive 240 ! means inversion, like in blast sop: delete non selected, so wouldnt it negate the * symbol? Like that: !* == (nothing) However, if I leave out !*, then it doesn't work. Hmm... using !* is dangerous as what it really means is 'all primitives that are not in any group', so if you have any primitive groups, it will automatically break for your case so instead of !* ^240 just use !240 Edited February 12, 2017 by anim 1 Quote Link to comment Share on other sites More sharing options...
Juraj Posted February 13, 2017 Author Share Posted February 13, 2017 Great info, thanks much 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.