GDL
About building parametric objects with GDL.

Library global array

kmcw
Contributor

HI I have A global object with a parameter xy[16][16]

Now I want to find the easiest way to get the content of xy[5][6].

 

The only way I actually get a result is:

k=LIBRARYGLOBAL ("glob_obj", "xy", cont_1, cont_2, cont_3,...) where  cont_1=xy[1][1], cont_2=xy[1][2], cont_3=xy[1][3]

 

I have 16 cloums so i guess i'll need to go until ...,cont_15,cont_16,cont_17) to make cont_17 the field xy[2][1]  but I havn't tried that.

 

Is there no more efficient way to "call" the content of a field?

 

5 REPLIES 5
Jochen Suehlo
Moderator

Please read this topic:

https://community.graphisoft.com/t5/GDL/LIBRARYGLOBAL-vs-2-dimension-array/m-p/252379#M2866

Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de

sorry, that comunication doesn't help me. They are talking about calling obejects etc...

Read carefully then. The concept is the same!

To quote myself and the GDL manual:

"Requests (and Libraryglobal is also a request) do not handle two-dimensional arrays."


And Kristian shows how to convert it back to a 2D array from a 1D one.

Only difference: You'll need to now the dimensions yourself, the request doesn't return them.

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»

The entire array has to be read up to the point of the number you wish to get,

either

k=LIBRARYGLOBAL ("glob_obj", "xy", cont_1, cont_2, cont_3,...)

 

or ..................

use an array function to read all the variables and then reconstruct the array in the new file

 

I set the array sizes in the global

!!------this bit is just to set some values for this test
for j = 1 to 16
  for ii = 1 to 18
    xy[ii][j] = ii*100+j
  next ii
next j
parameters xy = xy
!!------this bit is just to set some values for this test

!!------this bit measures the size of the array and sets it as variables that can be read
xy_array1 = vardim1(xy)
xy_array2 = vardim2(xy)
parameters xy_array1 = xy_array1
parameters xy_array2 = xy_array2

!!------this bit measures the size of the array and sets it as variables that can be read

 

AllanP_6-1710369819043.png

AllanP_7-1710369834325.png

 

AllanP_13-1710371932634.png

 

 

then read the array,

you will see that the new array read will only be a 1 dimensional array

so a 1x288 rather than a 18x16 as per the original

!!!----READ THE ARRAY FROM THE LIBRARY GLOBAL INTO A NEW ARRAY "xy_Temp[][]"----!!
dim xy_Temp[][]

!!!___note you can just do a 1 dimensional array at this point   

!!!"dim xy_Temp[]"
success0 = LIBRARYGLOBAL ("1-test GLOBAL", "xy", xy_Temp)
success1 = LIBRARYGLOBAL ("1-test GLOBAL", "xy_array1", xy_array1)
success2 = LIBRARYGLOBAL ("1-test GLOBAL", "xy_array2", xy_array2)

!!!!if just reading from the array then you could just use
co_ordinate1 = (xy_array2)*(6-1)+5
text2 0,1, vardim1(xy_Temp)
text2 0,2, vardim2(xy_Temp)
text2 0,3,xy_array1
text2 0,4,xy_array2
text2 0,5,xy_Temp[1][co_ordinate1]

!!!----CONVERT 1 DIMENSIONAL ARRAY BACK TO 2 DIMENSIONAL ARRAY----!!
dim xy[][]
for j = 1 to xy_array1
for i = 1 to xy_array2
co_ordinate = (j-1)*xy_array2+i
xy[j][i] = xy_Temp[1][co_ordinate]
next i
next j
text2 0,7,xy[6][5]
parameters xy = xy

 

AllanP_10-1710371807307.png

AllanP_12-1710371884362.png

 

I hope this helps

 

P.S.

if you don't want to convert it back to an array you only need :

dim xy_Temp[]
success0 = LIBRARYGLOBAL ("1-test GLOBAL", "xy", xy_Temp)
success2 = LIBRARYGLOBAL ("1-test GLOBAL", "xy_array2", xy_array2)
co_ordinate1 = (xy_array2)*(6-1)+5
text2 0,5,xy_Temp[co_ordinate1]

and if the size of the array is always know(it wont change in the future) then you can replace the xy_array2 part with the fixed number.

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

Thank you very much, I'll try that as soon as I have time.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!