logix1390 Posted March 20, 2017 Share Posted March 20, 2017 Hello, I have some lines, and I want to add points to each line based on the length of the line. The longer the line, the fewer points I want to add , and the shorter the line , the more points I want to add. I have already calculated the perimeter of each line and stored the values in an attribute called " perm". After I isolated one line inside the foreach, I add the Resample node. I want to get the resample "length" parameter and divide it by the attribute "perm" to see what happens. I have a point expression in the "Length" paramter of the resample to reference in the values of the perm attribute but it's not working...point(opinputpath(“.”,0), $Ptnum, “perm”,0) Is there something here I'm missing? I attached my file If anyone wants to take a look. Thank you. resample_by_length_Polylines.hip Quote Link to comment Share on other sites More sharing options...
jon3de Posted March 20, 2017 Share Posted March 20, 2017 (edited) hm maybe this is not what you looking for because its not proportional to the segment length but you can use the ptdist to delete if the points are x units apart from each other? And ctrl the the resample size with the segments count...I attached the file. resample_by_length_Polylines.hip Edited March 20, 2017 by jon3de Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 20, 2017 Share Posted March 20, 2017 After calculating their length, you can use a primwrangle on the lines. // user parameters float cut = chf('cut'); float change = chf('restlength'); // identify point positions int vtx_0 = primvertex(0, @primnum, 0); int vtx_1 = primvertex(0, @primnum, 1); int pt_0 = vertexpoint(0, vtx_0); int pt_1 = vertexpoint(0, vtx_1); vector pos_0 = point(0, "P", pt_0); vector pos_1 = point(0, "P", pt_1); // define slices based on user parameters @restlength = pow(@restlength, change); int slice = int( ceil(cut / @restlength) ); slice = max(slice, 2); // add new primitive with points and vertices int add_prim = addprim(0, "polyline"); for(int i = 0; i < slice; i++) { float mix = i / float(slice - 1); vector pos = lerp(pos_0, pos_1, mix); int add_pt = addpoint(0, pos); addvertex(0, add_prim, add_pt); } // remove the old primitives removeprim(0, @primnum, 1); counter_resample.hipnc 1 Quote Link to comment Share on other sites More sharing options...
acey195 Posted March 20, 2017 Share Posted March 20, 2017 with H16 what you can do is just rename your "perm" attribute to "segment_length" (or "num_segments" alternatively) and enable overriding attributes (should be enabled by default I think) 1 Quote Link to comment Share on other sites More sharing options...
logix1390 Posted March 20, 2017 Author Share Posted March 20, 2017 All of these methods worked, thanks everyone! 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.