The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Everything about GDL - Doors/Windows/Objects/Stairs etc. (Example: I created an object that prints an error message in 3D all the time, please help!)

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

By Michal K
#257211
Hi,

I'm trying to create object which displays it's creation date as a text.

Creation date means moment when object is placing on 2d view. I'm trying different conditions which prevent changing date after first run, with no effect.

Can anyone tell me if is that ever possible?

Here is example of one of my attempts:
Code: Select all
IF GLOB_VIEW_TYPE = 2 THEN			!do only in 2D 
		IF firstRun THEN				!parameter that allow to run code only once 
			ch = OPEN ("DateTime", "", "%Y/%m/%d, %H:%M%P") 
			n = INPUT (ch, "", "", date) 
			CLOSE (ch) 
			parameters firstRun = 0	!prevents running code again
			parameters date = date 
		ENDIF 
ENDIF 
User avatar
By Barry Kelly
#257226
Firstly you need to set the default value of your 'firstRun' parameter to "1" or anything other than zero.
However I would change this to ...
Code: Select all
IF GLOB_VIEW_TYPE = 2 THEN         !do only in 2D 
      IF firstRun = 0 THEN            !parameter that allow to run code only once 
         ch = OPEN ("DateTime", "", "%Y/%m/%d, %H:%M%P") 
         n = INPUT (ch, "", "", date) 
         CLOSE (ch) 
         parameters firstRun = 1   !prevents running code again 
         parameters date = date 
      ENDIF 
ENDIF 
Because the default value for 'firstRun' if not set will already be zero.



Having said that I am not sure if this is a bug or not.
GLOB_VIEW_TYPE = 2 does not work as the 'firstRun' parameter is set while you are in the library part editor and you can not change it.
Try and change it manually in the parameter list and you can't.
If you change it to GLOB_VIEW_TYPE = 3 (just as an experiment) you will find that you can change the parameter value.

You need a way to block the library part editor from running this part of the script.
Back in version 18 (and before) we could use 'IF GLOB_CONTEXT <> 1' but this is no longer available in 19/20.
And there is no equivalent command to detect that you are in the library part editor any more.

Barry.