We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

GDL
About building parametric objects with GDL.
SOLVED!

Question about parameter Arrays and updating values (not for beginners)

Nader Belal
Mentor
Ok,

I have a bunch of arrays that I have tried by many means update values and I have failed.

I have tried to force their update in the parameter script and in the master script, and it doesn't updates at all, whether by direct editing those values to the parameter array itself, or indirectly to the temporary variable array then to a parameter array.

What should I do for those cases ??

PS: This question is not for beginners
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Nader Belal
Mentor
To all

1. I want to thank @Kristian Bursell & @Barry Kelly for you quick reply.

2. You assumed that I didn't use a temporary array, but unfortunately before posting my question, I have already used that method, and it didn't work, although array values in the memory have been successfully modified, but didn't pass the new values to the parameter arrays.

3. The funny part, (Thank you Google), have reminded me that I've already stumbled on that same problem ... and also reminded me that I was the one how have solved it (here & here)...

The error was happening because of a line of code

n = APPLICATION_QUERY ("PARAMETER_SCRIPT", "FIRSTOCCASION_IN_PROGRESS", _isFirstRun)

That was the one that was generating all this problem and preventing value transaction to the parameter arrays, and just by eliminating that line, everything was working as it should.
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.

View solution in original post

6 REPLIES 6
Barry Kelly
Moderator
I do this to reset an array in a stretchy polygon object I have.
"reset_defaults_swch" is just a boolean parameter to trigger the reset.
This works for me.
I guess you could also use a FOR/NEXT loop to set all of the values if it is a larger array.
In this case I just want to reset to seven known co-ordinate positions.
if reset_defaults_swch = 1 then
DIM ac_coords[7][2]
	ac_coords[1][1] = 0.000
	ac_coords[1][2] = 0.000

	ac_coords[2][1] = 0.000
	ac_coords[2][2] = 1.000

	ac_coords[3][1] = -1.000
	ac_coords[3][2] = 1.000

	ac_coords[4][1] = -1.000
	ac_coords[4][2] = 0.000

	ac_coords[5][1] = 0.000
	ac_coords[5][2] = 0.500

	ac_coords[6][1] = -0.500
	ac_coords[6][2] = 1.000

	ac_coords[7][1] = -1.000
	ac_coords[7][2] = 0.500
	
	parameters ac_coords = ac_coords


	reset_defaults_swch = 0
	parameters reset_defaults_swch = reset_defaults_swch

endif


Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Is it the values in the array cells you cant edit? if so try:
assuming array parameter is a string type called "arrayName" and it is 2 dimensional ([][]).

dim _arrayName[][]

for i = 1 to vardim1(arrayName)
    for j = 1 to vardim2(arrayName)
        _arrayName = "Test"
    next j
next i

arrayName = _arrayName
parameters arrayName = arrayName
This will populate every single cell of the array with the value "Test". if this doesn't work for you then there must be another script overwriting this script. Once you get this to work then you can focusing just on a specific cell but you should keep the loop statements so that both the the temporary and parameter arrays are the same size (vardim1 and vardim2).

one important thing to remember is that if your temporary and parameter arrays are kept identical then it is actually faster to use the temporary array values rather than the parameter array values in your other scripts. The reason for this is you don't have to wait for the values to pass through to the parameter hence the object will update without a refresh. This is critical if you are doing auto labels and want an instantaneous response.
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
Solution
Nader Belal
Mentor
To all

1. I want to thank @Kristian Bursell & @Barry Kelly for you quick reply.

2. You assumed that I didn't use a temporary array, but unfortunately before posting my question, I have already used that method, and it didn't work, although array values in the memory have been successfully modified, but didn't pass the new values to the parameter arrays.

3. The funny part, (Thank you Google), have reminded me that I've already stumbled on that same problem ... and also reminded me that I was the one how have solved it (here & here)...

The error was happening because of a line of code

n = APPLICATION_QUERY ("PARAMETER_SCRIPT", "FIRSTOCCASION_IN_PROGRESS", _isFirstRun)

That was the one that was generating all this problem and preventing value transaction to the parameter arrays, and just by eliminating that line, everything was working as it should.
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
gotta love that digital memory
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
Nader Belal
Mentor
What embarrassing infuriates me is the fact I 've stumbled on the same problem, twicce
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
Nader Belal
Mentor
@Barry Kelly & @Kristian Bursell

Guys, I think I have found a glitch in the GDL

I think that "Parameters" function or the GDL script when converted to Binary can suffer from what I call stuttering, and that is when you have a library part with multiple similar parameters names ...

Let me explain ....

When working with an object that needs a myriad of parameters (array or not), the use of keywords becomes a necessity as it permits the GDL scriptor/programmer to have variables or parameters with longer descriptive names using a reduced number of characters.

The problem will arise when the name of these parameters have a number of starting and ending characters that are practically equal ...

example:

bVar_turnOnLights

bVar_turnOffLight

As you can see, similarly named parameters may cause the library part to not function properly ....

I don't know if it's a GDL bug or not, but I will will confirm after finishing my tests on the same object that made me start this thread

A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.