GDL
About building parametric objects with GDL.

how to know if the script is being run in library editor

easyDoesIt
Booster

I have a label that I have setup to only run associated to a door. When not a door, it ends quite quickly with a warning message. This it turn creates a problem in the library editor because it is not yet associated with a door. I can have a variable that I turn on temporarily while coding but wonder if there is a global variable or request I can use to see if the script is run in the library editor and therefore automate it.

 

GLOB_ELEM_TYPE can't be used because it is 0 both when not placed AND when as an independent label.

Cheers,
Mark
Brisbane, Australia
9 REPLIES 9
Jochen Suehlo
Moderator

I haven't used, but possible it works:

GLOB_DIAGNOSTICS_MODE together with Developer Menu.
or GLOB_CONTEXT = 1 (but it is depracted and only works in 2D, 3D and UI)

Jochen Suehlo . AC12-27 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de

Thanks Joachim,

 

I used to use glob_context back in the day but worry it is deprecated now so might be unstable.

 

I was looking into glob_diagnostic_mode with the developer menu but couldn't work it out. Will look into it further.

Cheers,
Mark
Brisbane, Australia

Got the GLOB_DIAGNOSTICS_MODE working. But only works outside of library editor.....

Cheers,
Mark
Brisbane, Australia
Peter Baksa
Graphisoft
Graphisoft

Hi,

 

Archicad Library uses this:

 

bDefaultElem		= (GLOB_INTGUID = "" | GLOB_INTGUID = "{00000000-0000-0000-0000-000000000000}")
_isEnabledContent	= (bDefaultElem | GLOB_ELEM_TYPE = ...)

if not(_isEnabledContent) then
    ... ! show message on plan / UI
    end
endif

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
easyDoesIt
Booster

Thanks Peter, this works in the library editor. But it also turns on the default element type when the user has not yet placed the label as a GUID has not yet been assigned. Ideally I want it to trigger in the library editor only. GLOB_DIAGNOSTICS_MODE seems like the best method if it worked in the library editor also. Would be good if this made it into an update.

Cheers,
Mark
Brisbane, Australia

There is a very stupid workaround:

Make a new parameter called AC_ProgramVersion (type being "integer").

As soon as the object is placed a number (e.g. 26) will be assigned, so you can just test if that param is zero.

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | 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»

Try GLOB_PREVIEW_MODE, it is 1 in the settings dialog, and 0 in GDL editor. I am not sure it works according to your needs with the infobox and favorites.

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Thanks @runexel, sorry for the delayed response, nice workaround for managing placement, will use this for other instances. In my case I want to be able to initiate some code when in the library editor but turn off for the user, be it placed or not.

Cheers,
Mark
Brisbane, Australia

Sorry for the late reply, thanks @Peter. I just did a quick test, I put this line of code in the 2d script

 

if GLOB_PREVIEW_MODE = 0 then text2 0,0,"GDL Editor only."

 

the text appeared in plan view also (outside of gdl editor).

 

I think i give up, I will just comment in and out what I need to do while coding and rely on QA to ensure commented out in final release.

Cheers,
Mark
Brisbane, Australia