mrcoolmen Posted August 10, 2017 Share Posted August 10, 2017 Hey, thank you so much for your time to look at my post, just wondering how to store the point number in a attribute arrary? what i mean is if i have 4 points how can i loop through the point and get i[]@myarray={1,2,3,4} ? Quote Link to comment Share on other sites More sharing options...
Hartman- Posted August 10, 2017 Share Posted August 10, 2017 What you want to do here is to run a wrangle as a detail (so it will only run once) and then loop through the points. This way, you can build upon the array and then set the array to each point. See attached file! Create_Point_Array.hiplc 1 Quote Link to comment Share on other sites More sharing options...
mrcoolmen Posted August 10, 2017 Author Share Posted August 10, 2017 thk u hartman, its exactly wat im looking for Quote Link to comment Share on other sites More sharing options...
mrcoolmen Posted August 10, 2017 Author Share Posted August 10, 2017 1 hour ago, Hartman- said: What you want to do here is to run a wrangle as a detail (so it will only run once) and then loop through the points. This way, you can build upon the array and then set the array to each point. See attached file! Create_Point_Array.hiplc Hey Hartman, Just a follow up question, the idea of append(points,i) it make sense to me. however, i tried to append a custom attribute than it return me a weird result such as append(points,@id) den it does not really work, just curious wat did i do wrong? Quote Link to comment Share on other sites More sharing options...
ikoon Posted August 10, 2017 Share Posted August 10, 2017 @mrcoolmen you are running over the detail, so append(points,@id) looks for @id as a detail attribute, you may need to read @ from point first, and then append for (int i=0; i<@numpt; i++) { int id = point(0,"id",i); append(points, id); } @Hartman- please, why is this line necessary? and why is it outside the loop?addpointattrib(0, "allpoints", points); Quote Link to comment Share on other sites More sharing options...
petz Posted August 10, 2017 Share Posted August 10, 2017 to write point numbers to an array in detail mode you could just do: i[]@points = expandpointgroup(@OpInput1, "!"); or in point mode: int point[] = array(@ptnum); setdetailattrib(geoself(), "points", point, "append"); however, depending on the number of points, the second method might be slightly slower compared to iterating over points in detail mode ... 4 Quote Link to comment Share on other sites More sharing options...
mrcoolmen Posted August 10, 2017 Author Share Posted August 10, 2017 Guys, thk you so much to with my learning, really appreciate it Quote Link to comment Share on other sites More sharing options...
Hartman- Posted August 10, 2017 Share Posted August 10, 2017 3 hours ago, petz said: to write point numbers to an array in detail mode you could just do: i[]@points = expandpointgroup(@OpInput1, "!"); or in point mode: int point[] = array(@ptnum); setdetailattrib(geoself(), "points", point, "append"); however, depending on the number of points, the second method might be slightly slower compared to iterating over points in detail mode ... Those are much simpler than mine, now I'm learning! Quote Link to comment Share on other sites More sharing options...
Hartman- Posted August 10, 2017 Share Posted August 10, 2017 6 hours ago, ikoon said: @mrcoolmen you are running over the detail, so append(points,@id) looks for @id as a detail attribute, you may need to read @ from point first, and then append for (int i=0; i<@numpt; i++) { int id = point(0,"id",i); append(points, id); } @Hartman- please, why is this line necessary? and why is it outside the loop?addpointattrib(0, "allpoints", points); It's what made sense to me at the time, it works but I should probably revisit my logic. Was a bit tired when I made the example! 1 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.