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

LOCK Not Locking!

Anonymous
Not applicable
I have several LOCK functions in my Master Script that are meant to lock parameters depending on other values. I have at least 3 of them that won't lock the parameter. I've checked it from every angle -- spelling, punctuation, syntax, order of evaluation, extraneous code, etc. -- and nothing has solved the problem, they just will not lock. I've spent at least 3 hours trying to solve this problem.

The following code is used in a dozen places, only using different parameter names each time.

IF DCA_Deadbolt = `-` THEN
PARAMETERS DCA_Deadbolt_Qty = `-`
LOCK `DCA_Deadbolt_Qty`
ELSE
IF DCA_Deadbolt_Qty = `-` THEN
PARAMETERS DCA_Deadbolt_Qty = `1`
IF TypeChar <> `D` THEN
PARAMETERS TempVal = "HELLO" ! This line works
LOCK `DCA_Deadbolt_Qty` ! This line DOESN'T
ENDIF
ENDIF
ENDIF

The test line with TempVal works, which tells me the IF function preceeding it is working correctly. There is absolutely no reason the LOCK function shouldn't work. Is this a bug, or am I missing something? I realize it's Friday afternoon, but I can't be THAT delirious.
16 REPLIES 16
Anonymous
Not applicable
Have you tried the script in the Parameter Script?
__archiben
Booster
try with double and single quotes as well as the back ticks?
LOCK "DCA_Deadbolt_Qty"
(by the way - the single, double and back ticks around the parameter value all lock for me . . . .)

~/archiben
b e n f r o s t
b f [a t ] p l a n b a r c h i t e c t u r e [d o t] n z
archicad | sketchup! | coffeecup
Frank Beister
Moderator
PARAMETERS and LOCK should first of all be part of the parameters script. They do not work in all context!

Where does TypeChar come from? Maybe TypeChar<>"D" in the moment PARAMETERS works in master and LOCK does not. In a later iteration of the master script, when LOCK would work, maybe TypeChar="D".

As I wrote here a few times: The scripts are executed more than once, esp. the MASTER. And not all stements work in each run. So put in the MASTER as far as possible just common expressions, which are necessary for all script types.

Have you tried
LOCK `DCA_Deadbolt_Qty`
without any dependance of another expression?
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
F. wrote:
Where does TypeChar come from?
It was defined at the beginning of the Master Script.

TypeChar = STRSUB(DCA_Type, 1, 1) !DCA_Type is a string code
F. wrote:
Maybe TypeChar<>"D" in the moment PARAMETERS works in master and LOCK does not. In a later iteration of the master script, when LOCK would work, maybe TypeChar="D".
Refer back to my first email. The line immediately preceeding the LOCK line works exactly as expected. The LOCK line is ignored. There are no other LOCK statement after this one, and there are no other LOCK statements in any other script.
F. wrote:
Have you tried
LOCK `DCA_Deadbolt_Qty`
without any dependance of another expression?
Yes, I tried it as the very last line in the Master Script and it worked just fine. The statement LOCK `DCA_Deadbolt_Qty` is only used in two other situations, both of which occur before the failing instance, and both of those function properly.

My next post (after a meeting I must attend) will include the GDL and an explanation about how to test the faulty line.
Frank Beister
Moderator
The line immediately preceeding the LOCK line works exactly as expected. The LOCK line is ignored.
This I wanted to explain to you. There is no problem with the syntax of your LOCK command. I try it again. Would be easier in German. 😉

Most commands are allowed in Master-Skript, but they do not work in each context. If they make no sense (from the view of the gdl interpreter) they will be just ignured. Example:
LINE2 0,0,1,1
BLOCK 1,2,3
Changing to the floor plan view first the master script is executed, then the 2D-Script. The line of the master will be visible, the block, of course, not. In the 3D-window the block, but not the line is visible.

Lets modify the script:
IF doyouwant="yes" THEN
LINE2 0,0,1,1
BLOCK 1,2,3
ENDIF
Works as well as the first example. Some more:
IF GLOB_CONTEXT=2 THEN doyouwant="yes" ELSE doyouwant="no"

! [... anycode]

IF doyouwant="yes" THEN
LINE2 0,0,1,1
BLOCK 1,2,3
ENDIF
Now the block will not be visible anywhere, but the line in 2D.

Transferred to your problem:

In the moment the PARAMETERS statement is executable in master script TypeChar is unequal to "D". In a later execution of the master-script, when the LOCK command would work, TypeChar is equal to "D" and the line is not executed, because the IF-THEN is not true.

The Master-Script is executed many times, before the complete object is calculated. Just in the settings dialog:

E.g.:
Master > Parameter > parameter-reset > Master > User interface > parameter-reset > Master > 2D-view

I am asking GS a long time to give us a list, which parameters do work in which context in the master and how the scripts are executed exactly!

P.S. the scripts above are not tested. Maybe there are some minor syntax faults.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Frank Beister
Moderator
Or try this one:
IF GLOB_CONTEXT=2 THEN
PROJECT2 3,270,2
ROTx 45 : ROTy 45
BLOCK 1,2,3
ENDIF
Block is visible in 2D, but not in 3D or settings dialog. And it is visible in case the BLOCK-command is after the PROJECT2-command. Do you see, what I mean?

To help with your problem we need to see more of your code, because the "fault" is not as near to the LOCK-command.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
Wow! That is interesting (in a painful way)! I would think that TypeChar = STRSUB(DCA_Type, 1, 1) would be set regardless -- it's the first code line in the Master Script.

The attached GDL is the problem door. If you search for LOCK PROBLEM you will find one of the offending LOCK lines. To get the problem to rear it's ugly head, perform the following steps in the Parameters section of the settings dialog:

1 - Insert an instance of the door.
2 - Open the settings dialog, go to the Parameters section and expand the DCA Door Parameters title.
3 - Set Leaf Material to SCWD, and Leaf Type to NL.
4 - Scroll down to Lock Type. If Lock Type is a dash, there is not lock on the door, so the Lock Quantity is also a dash and it is locked.. If you choose a Lock Type, you automatically have a Lock Quantity of 1. I want to lock the quantity so the user knows it's the only option.

The reason I don't just lock it and leave it is because there is the possibility of a Dutch door being specifed -- which can have up to 2 locks on it. Wherever you see TypeChar = `D` or TypeChar <> `D` I'm checking to see if it's a dutch door.

It seems pretty simple to me, but what a pain this has been!
Anonymous
Not applicable
Hello Jay

I also had big problems with the "Lock" function on several parameters in the Master Script, also on a Door, also with a If Then Statement.
Incidentally I have had also had problem with the function "Hideparameter" in Master Script.

I have try a lot of things and the only solution which works every time is to have them in the Parameter Script and only there. Same way for "Hideparameter".

I can't test your door because I stay in AC81, but I am almost sure that your problem is there…
Anonymous
Not applicable
Fmr wrote:
...the only solution which works every time is to have them in the Parameter Script and only there.
I moved all the code that deals with PARAMETERS and LOCK to the Parameter Script -- no luck, it still misbehaves.

Thanks anyway!

I'm not sure how this squares with DNC's view that most of that stuff should be in the Master Script. If I understand this thread correctly, the Master Script is run repeatedly, where the Parameter Script is only run in certain instances. If so, it would seem that you would put it in the Parameter Script for speed, or the Master Script for constant validation.

Hmmm...