I have some x,y,z data points of a tunnel. My goal is to take these points and make a 3 dimensional array where each 3rd dimension of the array is a list of x,y,z points that make up a profile. The attached image shows one such example of the data points. As you can see, there are 18 distinct profiles. I would like to separate the points belonging to the profiles into arrays so that I can use these new sub data sets to draw splines trough the points of each profile. I've already written code to find which points belong to a profile. I do this by sorting from minimum x to maximum x and then look for a difference between x coordinates that exceed a threshold value I set. This is done in a loop. When the threshold value is exceeded, it means the previous points belong to a profile. Here is where I would like to assign the current points to a place in the 3 dimensional array. Each profile may or may not have the same number of points as other profiles.

How do I create, within my loop, a multi-dimensional array consisting of points belonging to distinct profiles? I know that this step would come after the threshold check.

6cefee0a64a2c8977e81a78a8eacb091.png