cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:
BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
GDL
About building parametric objects with GDL.

# Length/Size of one of the sub-arrays of a multi-dim array

Enthusiast
Hi
Is there a way to get the length/size of a sub-array of a multi-dimensional array?
```DIM myArray[][]
myArray[1][1] = 500
myArray[1][2] = 510
myArray[2][1] = 600
myArray[2][2] = 610
myArray[2][3] = 620
myArray[3][1] = 700
myArray[3][2] = 710
myArray[3][3] = 720
myArray[3][4] = 730```
VARDIM1(myArray[1]) !gives 4, but I need the size of just myArray[1], which is 2

I tried VARDIM2(myArray[1]) also but it doesn't give the required output.
32 REPLIES 32
Ace
We started here (I started) the thread called Open Source GDL Project - where users can exchange GDL scripts, ideas, macros and develop new tools in open source manner.
Enthusiast
Ah, okay.
Graphisoft
I think this might help:
```dict d
dim EMPTYARRAY[]

d.array[1].subarray = EMPTYARRAY
d.array[2].subarray = EMPTYARRAY

d.array[1].subarray[1] = 11
d.array[2].subarray[1] = 21
d.array[2].subarray[2] = 22

print d, vardim1(d.array[1].subarray), vardim1(d.array[2].subarray)
```
dushyant wrote:
In that case, multi-dim arrays might not be helpful for what I am trying to do. Thanks guys for the help.

Can dictionaries be looped through?
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Learn and get certified!