Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

LIBRARYGLOBAL vs 2-dimension array

Bruce
Booster
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
http://www.brucepwalker.com
https://www.mindmeister.com/65450406

-- since v8.1 --
AC22 6025 INT Full | macOS Mojave 10 | 3.2 GHz Intel Xeon W | 32 Gb RAM | Radeon Pro Vega 56 8 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
Booster
Thanks Kristian. I was hoping that wasn't going to be the answer...
Bruce Walker
http://www.brucepwalker.com
https://www.mindmeister.com/65450406

-- since v8.1 --
AC22 6025 INT Full | macOS Mojave 10 | 3.2 GHz Intel Xeon W | 32 Gb RAM | Radeon Pro Vega 56 8 Gb

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-25 . MAC OSX 10.15 . WIN10

runxel
Mentor
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...)
AC 24 [ger] | Win 10 | 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
Booster
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
http://www.brucepwalker.com
https://www.mindmeister.com/65450406

-- since v8.1 --
AC22 6025 INT Full | macOS Mojave 10 | 3.2 GHz Intel Xeon W | 32 Gb RAM | Radeon Pro Vega 56 8 Gb

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!