AntoineSfx Posted August 16, 2018 Share Posted August 16, 2018 Given two points in input, why doesn't this work: in point wrangle / detail : setpointattrib(0, "order", 0, 0 , "set"); setpointattrib(0, "order", 1, 10 , "set"); for(int i=1;i<10;i++) { float f= (float)i / 10; int a=addpoint(0, lerp(point(0,"P",0), point(0,"P",1), f)); setpointattrib(0, "order", a, f, "set"); } I'm trying to add points, and keep track of when it was added in the loop The setpointattrib in the loop has no effect. I assume that I can't setpointattrib until after the whole node is cooked ? Quote Link to comment Share on other sites More sharing options...
animatrix Posted August 17, 2018 Share Posted August 17, 2018 Your code is ok, but order is a known attribute of type int by default. That's why you don't see the correct value. Quote Link to comment Share on other sites More sharing options...
bhouse Posted August 17, 2018 Share Posted August 17, 2018 If I understand correctly, this should give you the behavior you want. (file attached) setpointattrib(0, "order", 0, 0 , "set"); setpointattrib(0, "order", 1, 10 , "set"); for(int i = 1; i < 10; i++) { int order = i; float pos = (float)i/10; int newPoint = addpoint(0, lerp(point(0,"P",0), point(0,"P",1), pos)); setpointattrib(0, "order", newPoint, order, "set"); } setpointattrib.hip Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted August 17, 2018 Author Share Posted August 17, 2018 (edited) So I got this working: here is the fix: setpointattrib(0, "order", 0, 0. , "set"); The type of the order attribute is determined by the type of the fourth argument, when called first on order (creation of the attribute) Here I added a point after the 0 to force the parser to see it as a float. After that the attribute is created as a float, and everything makes sense. Alternatively, passing a float variable as the fourth argument will work too. Edit.. float f=0; setpointattrib(0, "order", 0, f , "set"); setpointattrib(0, "order", 1, 1.0, "set"); <<<--- 1.0 works as expected float f=0; setpointattrib(0, "order", 0, f , "set"); setpointattrib(0, "order", 1, 1, "set"); <<< --- 1 point #1 has order set to 0 when the argument is an int, any integer really.. Edited August 17, 2018 by AntoineSfx 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.