jkunz07 Posted August 25, 2015 Share Posted August 25, 2015 Hey, I'm probably doing something terribly wrong here - but I'm not sure why this code acts as if it's only operating over a single primitive instead of all of them. I have a attribwrangle set to 'primitives' mode with the following code: float target_upos = chf('point_uu'); int spline_pt_list[] = primpoints(0, @primnum); int closest_ptnum = -1; float dist = 1; vector found_uv = set(0,0,0); foreach(int i; spline_pt_list) { found_uv = point(0, "uv", spline_pt_list[i]); if( abs(target_upos - found_uv.x) < dist ) { dist = target_upos - found_uv.x; closest_ptnum = i; } } vector new_pt_pos = point(0, "P", closest_ptnum); int new_pt = addpoint(geoself(), new_pt_pos); addattrib(geoself(), "point", "pt_list", primpoints(0, @primnum) ); setattrib(geoself(), "point", "pt_list", new_pt, 0, spline_pt_list, "set"); removeprim(geoself(), @primnum, 1); int new_prim = addprim(geoself(), "polyline"); However when the 'point_uu' slider is adjusted, only one point changes position? My file is attached:primpoints_test.hip Thanks! Quote Link to comment Share on other sites More sharing options...
jkunz07 Posted August 25, 2015 Author Share Posted August 25, 2015 sorry, I've found the error in my code: foreach(int i; spline_pt_list) { found_uv = point(0, "uv", spline_pt_list[i]); if( abs(target_upos - found_uv.x) < dist ) { dist = target_upos - found_uv.x; closest_ptnum = i; } } becomes: foreach(int i; spline_pt_list) { found_uv = point(0, "uv", i); if( abs(target_upos - found_uv.x) < dist ) { dist = target_upos - found_uv.x; closest_ptnum = i; } } and it works as expected for me now. 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.