Handling DataTree and inserting items in bulk

Hello!
I am trying to handle and sort a pretty long list of reference points (for context, I am referencing these points in Archicad) and need to process a large list of null and point values so that I can insert a specific amount of null values between consecutive point values.
Basically, I am trying to get a Python script that can insert an “x” amount of nulls whenever there are two consecutive non-null values, without deleting pre-existing nulls or rearranging the order. This is an example of how the script would perform:

Any help is super appreciated!

indices = []
for i in range(len(points) - 1):
    if points[i] is None: continue
    if points[i + 1] is None: continue
    indices.append(i + 1)
for offset, index in enumerate(indices):
    adjusted_index = index + offset * n
    points[adjusted_index:adjusted_index] = [None] * n
a = points

Daniela.gh (12.0 KB)

1 Like