cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
GDL
About building parametric objects with GDL.
SOLVED!

Gracefully handle macro call when macro is missing - is this possible?

Davor P
Booster

Looking for a way to gracefully notify user if they don't have the necessary macro loaded in the library.

BIM4BIM - by BIM managers for BIM managers
www.bim4bim.com | audit.bim4bim.com
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
runxel
Hero

As you probably found out already if you directly call a macro and it's not available the whole object "crashes". Sadly there is no direct way to handle this gracefully, but I found a workaround:

rrr = LIBRARYGLOBAL("object name", "name_of_some_param", value)

If you use the LIBRARYGLOBAL command/request you its result will either be 0 or 1, and if it's 0 it means the object is not in the loaded library (GDL does not actually know beforehand if an object is a true library global or not, that's why this will work without complains!).

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Akroter.io – high-end GDL objects | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text

My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»

View solution in original post

7 REPLIES 7
Solution
runxel
Hero

As you probably found out already if you directly call a macro and it's not available the whole object "crashes". Sadly there is no direct way to handle this gracefully, but I found a workaround:

rrr = LIBRARYGLOBAL("object name", "name_of_some_param", value)

If you use the LIBRARYGLOBAL command/request you its result will either be 0 or 1, and if it's 0 it means the object is not in the loaded library (GDL does not actually know beforehand if an object is a true library global or not, that's why this will work without complains!).

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Akroter.io – high-end GDL objects | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text

My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
Davor P
Booster

Thanks Lucas, that works perfect!

BIM4BIM - by BIM managers for BIM managers
www.bim4bim.com | audit.bim4bim.com

Thanks for this Runxel,

 

An interesting limitation I found is I can't use A,B, or ZZYZX. It seems to get a return value from somewhere? so rrr = 1 in this case. Any other parameter is ok, if missing rrr returns 0.

Cheers, Mark
archibites.tech | Wet Area Tool | Door Circulation Compliance | Multi-Label | Roof Slope | Wall Type Label
Brisbane, Australia

Probably due to A and B being default parameters for all object types and are hence always discoverable even if the placed object is not loaded. For science, what happens if you query ZZYZX for a missing 2D object?

 

Ling.

AC22-28 AUS 3110Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win11 | R5 2600 | 16GB | GTX1660

returns 1 for rrr and 1.000 for the value of the non-existent ZZYZX....

Cheers, Mark
archibites.tech | Wet Area Tool | Door Circulation Compliance | Multi-Label | Roof Slope | Wall Type Label
Brisbane, Australia
runxel
Hero

My guess is that there is a "flaw" in how this works internally. MVOs never have these parameters (since they make no sense in this context).

Placeable objects however do. The "result" may come from the subtype, where the A, B and ZZYZX values are set to 1.0.

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Akroter.io – high-end GDL objects | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text

My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
easyDoesIt
Booster

Most likely, although I managed to get a value of 4.4 for A in one instance, for a non existent library part, but couldn't repeat. 

Cheers, Mark
archibites.tech | Wet Area Tool | Door Circulation Compliance | Multi-Label | Roof Slope | Wall Type Label
Brisbane, Australia