Masoud Posted July 5, 2019 Share Posted July 5, 2019 Hi Guys; In point wrangle SOP, when I select some points (in group tab) to apply the codes, the last selected point always overwrite the other ones. It seems that point wrangle doesn't execute codes line by line, right? When I apply codes to points, one by one (I mean a point wrangle for each selected point) it works fine. Please take a look at my files (to visualize it, I applied my attribute to P.y ) : Attribute Ramp_02.hip Quote Link to comment Share on other sites More sharing options...
kleer001 Posted July 5, 2019 Share Posted July 5, 2019 (edited) The point wrangle runs once for every point, in order. So, your foreach is redundant. The current point number is i@ptnum (an integer), the current points position is v@P (a vector), the current points floating point attribute named blahblah is f@blahblah. If you want to set the y value in the P you can float var = rand(i@ptnum); v@P = set(v@P.x, var, v@P.z); Edited July 5, 2019 by kleer001 clarity Quote Link to comment Share on other sites More sharing options...
Masoud Posted July 6, 2019 Author Share Posted July 6, 2019 Thank you "kleer001", So, how could I handle situations like this? Quote Link to comment Share on other sites More sharing options...
Masoud Posted July 6, 2019 Author Share Posted July 6, 2019 Please help; The last point in group selection always overwrites everything. How could I solve this problem? Attribute Ramp_03.hip Quote Link to comment Share on other sites More sharing options...
anim Posted July 6, 2019 Share Posted July 6, 2019 functions that write to not current point like setpointattrib() or create new geometry like addpoint() etc. Are queued in point order and executed on a single thread after all multithreaded code However that doesn't really matter in your case as much as the fact that in the single wrangle point() function will never read the updated "y" attribute, it will always read it from the input from so that's why 2 wrangles work for you You can always flip your code to be other way around and therefore more multithread friendly Like make all points look within the certain radius for points 17 and 306 and in the loop of found points they will change @y accordingly, as each point will only change its own value it'll be able to read it back using @y within the for look as expected 1 Quote Link to comment Share on other sites More sharing options...
Masoud Posted July 7, 2019 Author Share Posted July 7, 2019 Thank you "anim"; Very good points. Honestly, I'm not that good at VEX to solve this. Quote Link to comment Share on other sites More sharing options...
anim Posted July 7, 2019 Share Posted July 7, 2019 something like this: vector P = @P; string ptgrp = "17 306"; float radius = chf("MaxDist"); int pts[] = nearpoints(0, ptgrp, P, radius); foreach(int pt; pts) { vector ptP = point(0, "P", pt); float dist = distance(ptP, P); float invdist = fit( dist , 0, radius, 2, f@y); f@y = invdist; } Attribute Ramp_03_fix.hip 1 Quote Link to comment Share on other sites More sharing options...
Masoud Posted July 8, 2019 Author Share Posted July 8, 2019 Wow, I learned a lot of new things. Thank you. 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.