The Global Archicad Community

Stay informed. Get help. Share your knowledge.

GDL language and objects, API, Add-ons, Script…

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy

Add the possibility to query if an object exists

Yes, absolutely
6
100%
No
No votes
0%
User avatar
By runxel
#318362
We can already do "APPLICATION_QUERY"s, but for images only.
I think we need also a way to check if an object exists. If it's not there, scripters could do a sensible replacement and prevent the whole object from failing.
By Braza
#318396
I recall dealing with this a long time ago...
If I remember well, I managed to do this with requesting folder names in the loaded library and file I/O operations.
Hope this helps.
User avatar
By runxel
#318403
Braza wrote:
Fri Oct 30, 2020 10:35 am
I recall dealing with this a long time ago...
If I remember well, I managed to do this with requesting folder names in the loaded library and file I/O operations.
Hope this helps.
Good hint, Braza!
How do you request the loaded folder names?
The FileMan I/O addon as far as I can tell only works with "physical" places – not with the embedded library e.g.

But in the end I think this wish is still valid. GDL consists of more workarounds then productivity features – Nobody can reasonably explain why something works, but only for a certain type?...
It's always the same: consistency is key.
By Braza
#318421
You are welcome runxel :)

I did a check the GDL reference manual (page 254) and actually there has been some new great improvements since my hard days of GDL coding... Its a new command called FILE_DEPENDENCE. Here it is:
EXTERNAL FILE DEPENDENCE
FILE_DEPENDENCE
FILE_DEPENDENCE "name1" [, "name2", ...]
You can give a list of external files on which your GDL script depends on. File names should be constant strings.
All files specified here will be included in the archive project (like constant macro names used in CALL statements and constant picture names
used in various GDL commands). The command works on this level only: if the specified files are library parts, their called macro files will
not be included.
The command can be useful in cases when external files are referenced at custom places in the GDL script, for example: ADDITIONAL_DATA
file parameters, data files in file operations.
Cheers,
User avatar
By runxel
#318431
Braza wrote:
Fri Oct 30, 2020 8:36 pm
Its a new command called FILE_DEPENDENCE.
This, .. uhm... doesn't help me at all. :(
It only tells Archicad to include files into the .pla, but I don't care for that (or well, I do, but not right now).

To make it more clear: My case is not that I call a macro that I have written – instead the user shall provide his own macros (I'm not the end user...) which then get utilized by my object.
This means: I really need to know, if the macro name the user has set is valid, since otherwise the whole object will fail. If I know, that the name is not valid, I can then prevent the calling of the macro.
By Braza
#318444
Ok. I got your point.
Then: Why not letting the end user define the name of the macro as a string parameter? :idea:
User avatar
By runxel
#318454
Braza wrote:
Sat Oct 31, 2020 10:28 am
Ok. I got your point.
Then: Why not letting the end user define the name of the macro as a string parameter? :idea:
Well, that is my intention.
The goal is a nice and well-thought UI/UX.
See, if the provided string is wrong, because, well, mistakes happen, I want to prevent the whole object from failing, because this makes for a bad UX – the user might not know that they typed the name in wrongly.

Or a different case I'm actually working one:
There are multiple macros to be used. Now, I will deliver some basic macros along the main object. But I want to give the user the possibility to use their own macros.
I could now say: okay, here is a big list of all macros, give me your own name for each of them. But not only this would be rather cumbersome, it also doesn't work, since there are endless ways of new macros (the list isn't finite, the macro names itself are generated on-the-fly....).
So, if such an edge case appears, I somehow need to circumvent the failing of the object and instead use some kind of generic placeholder, so it's clear to the user: "Help, I need a special macro here!"
By Braza
#318492
Ok...
Long shot here: Did you try IES?
GDL Reference Manual page 521 wrote:Ies files
n = APPLICATION_QUERY ("LIBRARY_MANAGER", "IES_FILES", ies_files_list)
This command returns the list of file names with .ies extensions loaded with the active libraries.
Try exchanging "IES_FILES" for "GSM_FILES" and storing it in "gsm_files_list"? :idea:
User avatar
By runxel
#318493
Braza wrote:
Mon Nov 02, 2020 10:16 am

Try exchanging "IES_FILES" for "GSM_FILES" and storing it in "gsm_files_list"? :idea:
Yeah but that is the feature I want. Right now that doesn't work ;)
By Braza
#318501
Ok... Last idea that come to my mind: Instead of letting the user define countless macro names, you could let the user enter a single macro folder location (c:MyProject/Macros) and use this location for a File Manager I/O add-on operation.
GDL Reference Manual page 614 wrote:GDL FILE MANAGER I/O ADD-ON
The GDL File Manager In-Out Add-On allows you to scan a folder for the contained files/subfolders from a GDL script.
Specify the folder you would like to scan by using the OPEN command.
Get the first/next file/folder name in the specified folder by using the INPUT command.
Finish folder scanning by using the CLOSE command.
Hope this helps.