GDL
About building parametric objects with GDL.

GDL: Array Parameter Defaulting to Zero

Lingwisyer
Guru

Hi all,

 

Any idea why the following is only changing the size of the sg_gridToggle sg_lengthToggle arrays and not their values?

 

IF sg_noStoreyAbove > sg_noBasement then
			sizetokeep = min(vardim1(sg_customName), sg_noStoreyAbove)
		
			! copy existing values
			dim sg_lengthCustom_temp[][]
			dim sg_lengthCustom2_temp[][]
			dim sg_lengthToggle_temp[][]
			dim sg_gridToggle_temp[][]
			dim sg_gridToggle_display_temp[][]
			dim lp1_temp[][]
			dim lp2_h_temp[][]
			dim lp2_v_temp[][]
			dim marker_flip_temp[][]
			dim marker_flip_display_temp[][]
			for i = 1 to sizetokeep
				sg_lengthCustom_temp[i][1]			= sg_lengthCustom[i][1]
				sg_lengthCustom_temp[i][2]			= sg_lengthCustom[i][2]
				sg_lengthCustom2_temp[i][1]			= sg_lengthCustom2[i][1]
				sg_lengthCustom2_temp[i][2]			= sg_lengthCustom2[i][2]
				sg_lengthToggle_temp[i][1]			= sg_lengthToggle[i][1]
				sg_lengthToggle_temp[i][2]			= sg_lengthToggle[i][2]
				sg_gridToggle_temp[i][1]			= sg_gridToggle[i][1]
				sg_gridToggle_temp[i][2]			= sg_gridToggle[i][2]
				sg_gridToggle_display_temp[i][1]	= sg_gridToggle_display[i][1]
				sg_gridToggle_display_temp[i][2]	= sg_gridToggle_display[i][2]
				lp1_temp[i][1]						= lp1[i][1]
				lp1_temp[i][2]						= lp1[i][2]
				lp1_temp[i][3]						= lp1[i][3]
				lp1_temp[i][4]						= lp1[i][4]
				lp2_h_temp[i][1]					= lp2_h[i][1]
				lp2_h_temp[i][2]					= lp2_h[i][2]
				lp2_h_temp[i][3]					= lp2_h[i][3]
				lp2_h_temp[i][4]					= lp2_h[i][4]
				lp2_v_temp[i][1]					= lp2_v[i][1] 
				lp2_v_temp[i][2]					= lp2_v[i][2]
				lp2_v_temp[i][3]					= lp2_v[i][3]
				lp2_v_temp[i][4]					= lp2_v[i][4]
				marker_flip_temp[i][1]				= marker_flip[i][1]
				marker_flip_temp[i][2]				= marker_flip[i][2]
				marker_flip_display_temp[i][1]		= marker_flip_display[i][1]
				marker_flip_display_temp[i][2]		= marker_flip_display[i][2]
			next i
		
			! initialize new values, will be skipped when decreasing size
			for i = sizetokeep + 1 to sg_noStoreyAbove
				sg_lengthCustom_temp[i][1]			= sg_length
				sg_lengthCustom_temp[i][2]			= 0
				sg_lengthCustom2_temp[i][1]			= 0
				sg_lengthCustom2_temp[i][2]			= 0
				sg_lengthToggle_temp[i][1]			= 1
				sg_lengthToggle_temp[i][2]			= 1
				sg_gridToggle_temp[i][1]			= 1
				sg_gridToggle_temp[i][2]			= 1
				sg_gridToggle_display_temp[i][1]	= "Show"
				sg_gridToggle_display_temp[i][2]	= "Show"
				lp1_temp[i][1]						= marker_length/4
				lp1_temp[i][2]						= marker_length/4
				lp1_temp[i][3]						= marker_length/4
				lp1_temp[i][4]						= marker_length/4
				lp2_h_temp[i][1]					= marker_length/4
				lp2_h_temp[i][2]					= marker_length/4
				lp2_h_temp[i][3]					= marker_length/4
				lp2_h_temp[i][4]					= marker_length/4
				lp2_v_temp[i][1]					= 0
				lp2_v_temp[i][2]					= 0
				lp2_v_temp[i][3]					= 0
				lp2_v_temp[i][4]					= 0
				marker_flip_temp[i][1]				= 1
				marker_flip_temp[i][2]				= 1
				marker_flip_display_temp[i][1]		= "Top"
				marker_flip_display_temp[i][2]		= "Top"
			next i
		
			! store array with new size
			sg_lengthCustom							= sg_lengthCustom_temp
			sg_lengthCustom2						= sg_lengthCustom2_temp
			sg_lengthToggle							= sg_lengthToggle_temp
			sg_gridToggle							= sg_gridToggle_temp
			sg_gridToggle_display					= sg_gridToggle_display_temp
			lp1										= lp1_temp
			lp2_h									= lp2_h_temp
			lp2_v									= lp2_v_temp
			marker_flip								= marker_flip_temp
			marker_flip_display						= marker_flip_display_temp
			parameters sg_lengthCustom				= sg_lengthCustom
			parameters sg_lengthCustom2				= sg_lengthCustom2
			parameters sg_lengthToggle				= sg_lengthToggle
			parameters sg_gridToggle				= sg_gridToggle
			parameters sg_gridToggle_display		= sg_gridToggle_display
			parameters lp1							= lp1
			parameters lp2_h						= lp2_h
			parameters lp2_v						= lp2_v
			parameters marker_flip					= marker_flip
			parameters marker_flip_display			= marker_flip_display

 

 

Snippet from this object.

 

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660 
6 REPLIES 6
Palawat
Advocate

You might want to add ;

sg_gridToggle = sg_gridToggle_temp

before ;

parameters sg_gridToggle = sg_gridToggle

Archicad 26, Windows 10, Corei7 3.4 GHz, 16 GB Ram.
https://www.indigofigs.com
https://www.facebook.com/indigofigs
DGSketcher
Legend

You could try resetting the parameter values with an empty array e.g.

Dim arrNull2 [1] [1]

arrNull2 [1] [1] = "initial value"

oldarray = arrNull2

parameters oldarray = oldarray

 

I have situations where my parameter arrays wouldn't downsize and rebuilding from an empty array seemed to cure it.

Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)
Lingwisyer
Guru

 

@Palawat You might want to add ;

sg_gridToggle = sg_gridToggle_temp

That was done just a few lines above.

 

@DGSketcher You could try resetting the parameter values with an empty array e.g.

Isn't that what DIM sg_gridToggle_temp[ ][ ] does? Or is there something else I should be doing?

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660 

I started doing that in order to force the original dynamic parameter array to shrink before repopulating it with updated values. Maybe Parameter Arrays are processed differently to simple variable arrays. Sorry I'm not a GDL expert and my solutions usually come from trial & error.

Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)
Lingwisyer
Guru

Might it be related to:

During the interpretation, when a non-existing dynamic array element is given a value, the necessary quantity of memory
is allocated and the missing elements are all set to 0 (numerical).

Though only these two arrays are doing it...

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660 
Lingwisyer
Guru

Hm... I partially fixed it... I realised that since I had combined the up and down arrays [u][d] the values between the short and tall sides [u][u-x] were not getting set in the short side of the array [u-d]. This was an easy enough fix.

 

 

 

sg_lengthToggle_temp[i][1]			= sg_lengthToggle[i][1]
sg_gridToggle_temp[i][1]			= sg_gridToggle[i][1]
sg_gridToggle_display_temp[i][1]	= sg_gridToggle_display[i][1]
IF i > sg_noBasement then
		sg_gridToggle_temp[i][2]			= sg_Toggle_default
		sg_gridToggle_display_temp[i][2]	= "Show"
		sg_lengthToggle_temp[i][2]			= sg_Toggle_default
	else
		sg_gridToggle_temp[i][2]			= sg_gridToggle[i][2]
		sg_gridToggle_display_temp[i][2]	= sg_gridToggle_display[i][2]
		sg_lengthToggle_temp[i][2]			= sg_lengthToggle[i][2]
endIF

...

========================================================================================

...

IF i > sg_noStoreyAbove then
		sg_gridToggle_temp[i][1]			= sg_Toggle_default
		sg_gridToggle_display_temp[i][1]	= "Show"
		sg_lengthToggle_temp[i][1]			= sg_Toggle_default
	else
		sg_gridToggle_temp[i][1]			= sg_gridToggle[i][1]
		sg_gridToggle_display_temp[i][1]	= sg_gridToggle_display[i][1]
		sg_lengthToggle_temp[i][1]			= sg_lengthToggle[i][1]
endIF
sg_lengthToggle_temp[i][2]			= sg_lengthToggle[i][2]
sg_gridToggle_temp[i][2]			= sg_gridToggle[i][2]
sg_gridToggle_display_temp[i][2]	= sg_gridToggle_display[i][2]

 

 

 

 

I was hoping my issue with increasing the overall array size would be solved in a similar way but this would seem to not be the case... So for [u][d], increasing d until it matches u, or viceversa, gives the correct default values, but increasing the max(u,d), still gives the incorrect return...

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660