Hi!
Lets say I have an array with numbers from 100 to 200 (representing @ptnum on a polyline) in a point wrangle. I want to remove all the points from the array that are before the current @ptnum. In other words, if I'm running over the point 50, the new array should be from 51 to 100;
The method I'm thinking of using is to do a foreach on the array and compare if the value is the same as my @ptnum and note what iteration(index) I was on and use the slice function later… This looks like a lot of processing and I'd like to know if there's a better method.
Thanks.
-Olivier
Vex: efficient array slice?
1196 2 0- olivierth
- Member
- 1004 posts
- Joined: 4月 2017
- Offline
- tamte
- Member
- 8525 posts
- Joined: 7月 2007
- Offline
you can use native array slicing
like this:
EDIT: note that @ptnum in the example is used directly as an index for the slice, so if your indices are not aligned with ptnumbers you need to find or compute the index you want to slice at first
[:]
like this:
int pts[] = expandpointgroup(0, ""); //get array of all points i[]@pts = pts[@ptnum:]; // get only slice starting with current @ptnum
EDIT: note that @ptnum in the example is used directly as an index for the slice, so if your indices are not aligned with ptnumbers you need to find or compute the index you want to slice at first
Edited by tamte - 2019年6月14日 12:10:30
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- olivierth
- Member
- 1004 posts
- Joined: 4月 2017
- Offline
-
- Quick Links