vijayakumar 17 Posted August 26, 2016 Hi guys, need help in vex. I tried creating an attribute in for loop and access the previous point value . But i couldn't access the created value. Here is the code. in this i am creating an integer a and storing the value. i am trying to use point(geoself) and access the previous point attribute but it defaults to zero. help me out with this.. thanks.. int @a=1; int @test[]; int @inst; if(@ptnum==0) @test[0]=1; for(int i=0;i<=@ptnum;i++) { @a=@a+i; if(@ptnum>0) { @inst=point(geoself(),'a',i-1); //cannot access the previous value @test=point(geoself(),'a',i-1); } } Share this post Link to post Share on other sites
f1480187 799 Posted August 26, 2016 (edited) You need to do such things in different wrangles, because geometry wrangles are writing attribute values at the very end of execution. // First Point wrangle. i@a = (@ptnum+1) * @ptnum / 2; // Second Point wrangle. i@a_prev = point(0, "a", @ptnum-1); Or use Detail wrangle, use explicit functions for setting attributes and keep track of previous values manually: // Detail wrangle. int a = 0; int a_prev = 0; addpointattrib(0, "a", a); addpointattrib(0, "a_prev", a_prev); for (int i = 0; i < @numpt; i++) { a_prev = a; a = (i+1) * i / 2; setpointattrib(0, "a", i, a); setpointattrib(0, "a_prev", i, a_prev); } The drawback of using Detail wrangle is that you need to use explicit functions, which is a bit more lines of code. It is also single-threaded, but still very fast in most cases. previous_point_value.hipnc Edited August 26, 2016 by f1480187 1 Share this post Link to post Share on other sites