GDL
About building parametric objects with GDL.

LIBRARYGLOBAL vs 2-dimension array

Bruce
Expert
I'm performing a LIBRARYGLOBAL request on a 2-dimension array in my MVO.

The MVO array parameter (call it zone_position_content) has dimensions [7][6]
However, when I perform the LIBRARYGLOBAL request, the returned array has dimensions [1][42]

What am I doing wrong? Do I have to re-shuffle the returned array to get it right?

The 2D script in my part (a zone stamp):
DIM tmpZonePositionContent[][]
success = LIBRARYGLOBAL ("BW_MVO", "zone_position_content", tmpZonePositionContent)
Bruce Walker
www.brucepwalker.com
Barking Dog BIM YouTube
Mindmeister Mindmap
-- since v8.1 --
AC26 5002 INT Full | Windows 11 64 Pro | 12th Gen Intel i7-12700H 2.30 GHz | 64 Gb RAM | NVIDIA GeForce RTX 3060 32 Gb
6 REPLIES 6
I think the answer is yes, as its a "returned parameters" type call.

When you call a macro and apply parameters to the macro from the master you can just force the master array on the macro array. But when your are wanting to force the macro array values on the master, you have to retrieve the values as a list (or single dimension array) and then reorganize them into you masters array.

I haven't done this with library globals but I have done it with a macro I use to retrieve external data. the code looks like this:

call "DataPort" parameters all, selector1 = "Assemb", returned_parameters _arraySize1, _arraySize2, arr_embedCClogAssembly	
for j = _arraySize1 to 1 step -1
	for k = _arraySize2 to 1 step -1
		_embedCClogAssembly = arr_embedCClogAssembly[(j -1)*_arraySize2 +k]
	next k
next j
embedCClogAssembly = _embedCClogAssembly
parameters embedCClogAssembly = embedCClogAssembly

yours will be different because you are using library globals and not a macro call but the logic is the same.
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
Bruce
Expert
Thanks Kristian. I was hoping that wasn't going to be the answer...
Bruce Walker
www.brucepwalker.com
Barking Dog BIM YouTube
Mindmeister Mindmap
-- since v8.1 --
AC26 5002 INT Full | Windows 11 64 Pro | 12th Gen Intel i7-12700H 2.30 GHz | 64 Gb RAM | NVIDIA GeForce RTX 3060 32 Gb
Joachim Suehlo
Advisor
In my opinion for Libraryglobals it is different than for macros. LIBRARYGLOBAL always returns parameters that are set in the Model view options to the "Caller" without the use of Returned Parameters.
For arrays this might be a bit different, because you do not only want to pass parameter values, but array dimensions as well.
Why the 6 x 7 Array Dimensions are passed as 1 x 42 is a bit mysterious.
I think with 1-dimensional Arrays it should work: please try to split the 2-dimensional array in different 1 dimensional arrays.
Joachim Suehlo . AC12-27 . MAC OSX 13.5 . WIN11
GDL object creation: b-prisma.de
runxel
Legend
As the GDL reference manual says:
"Requests (and Libraryglobal is also a request) do not handle two-dimensional arrays."

So... it worked "as expected" (well, not as you expected, but...)
Lucas Becker | AC 27 on Mac | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»
Peter Baksa
Graphisoft
Graphisoft
Hi,

It only works with dynamic arrays this way.
If your MVO parameter is fixed size, you can declare a fixed array in the receiving script, and it will remain two-dimensional.
DIM tmpZonePositionContent[7][6]
success = LIBRARYGLOBAL ("BW_MVO", "zone_position_content", tmpZonePositionContent)
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Bruce
Expert
Thanks Peter. Unfortunately, my arrays are dynamic size. I run them through a loop after the REQUEST to reorder into 2-dimensions. Ta.
Bruce Walker
www.brucepwalker.com
Barking Dog BIM YouTube
Mindmeister Mindmap
-- since v8.1 --
AC26 5002 INT Full | Windows 11 64 Pro | 12th Gen Intel i7-12700H 2.30 GHz | 64 Gb RAM | NVIDIA GeForce RTX 3060 32 Gb