Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

How to once to declare and initialize variable for many GDL elements

Anonymous
Not applicable
I need to declare and initialize array.
dim my_array[]
my_array[1]="1"
my_array[2]="2"
Count of the my_array items can be changed in time to development aims.
And need to use it in any my GDL elements of the library.
How I can declare andi initialize this array once for all my elements?
Help me please(.
4 REPLIES 4
Barry Kelly
Moderator
I have never tried it on multiple objects.
Maybe the LP_XMLConverter can do this - I have never used it but I believe it can reset variables in multiple elements.
I may be mistaken though - as i say i have never used it.

Otherwise you will need to do it individually in each object.
I have done this in an object I made so I can easily reset all the array values back to default while I am testing or changing the object.

Create a boolean parameter called "reset_defaults_swch"
Then add this to the master script (it may work in the parameter script as well, but for some reason I have it in the master script"
if reset_defaults_swch = 1 then
	dim my_array[]
	my_array[1]="1"
	my_array[2]="2"
	
	parameters my_array = my_array

	reset_defaults_swch = 0
	parameters reset_defaults_swch = reset_defaults_swch
endif
Now just turn on the boolean parameter in the parameter list - it will turn back of instantly but will have reset your array.

You could do it without the boolean switch but you would have to manually uncomment/comment the lines otherwise it will always be initialising.

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
Probably LibraryGlobal is a key - can be changed by MVO and then injected to the calling object.

Piotr
Barry Kelly
Moderator
Piotr wrote:
Probably LibraryGlobal is a key - can be changed by MVO and then injected to the calling object.

Piotr
I was going to mention Library Globals and MVO but I ended up deleting it.
That will work for resetting values in placed instances of the objects but not the object default (script) values themselves.

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
Ok, I missed the "main" part.
So there is another way but the XML tool:
- make an object with desired parameters and values
- set it as a template
- apply the template to the desired objects...
(delete the template when necessary ... when deleted it will be allowed to change the template without deleting the previously inserted parameters)

Piotr