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

Problem with REQUEST

Barry Kelly
Moderator
First I will explain what I am trying to do.
I have a 2D object placed on each storey of my plan.
In this I set default values required for energy efficiency calculations for glazing (i.e U-value, SHGC, shade overhang, shade height).
All this is fine and works well.
I REQUEST the home storey of the object and OUTPUT the values to a text file.

Here is the bit of script that does it and as I said all works well and the text (Excel) file is created.

rrr=REQUEST ("Name_of_plan", "", pname)
rrr=REQUEST ("Home_story", "", hsindex, hsname)

fspec="C:\Program Files\ArchiCAD 8.1\ArchiCAD Data Folder"+pname+"_BCA_window_default_settings.xls"
ch1 = open("data",fspec,"Separator='\t',Mode = WO")
OUTPUT ch1, hsname + " - U_value", 1, U_value
OUTPUT ch1, hsname + " - SHGC", 1, SHGC
OUTPUT ch1, hsname + " - Shade o/hang", 1, shade_ohang
OUTPUT ch1, hsname + " - Shade height", 1, shade_hgt
close ch1


The output in the file looks like this but in two tabbed columns (name and value).
Ground floor - Shade height 2.243
Ground floor - Shade o/hang 0.6
Ground floor - SHGC 0.81
Ground floor - U_value 7.9
Upper floor - Shade height 2.4
Upper floor - Shade o/hang 0.4
Upper floor - SHGC 0.95
Upper floor - U_value 8.2



Now the problem comes with my doors and windows.
These objects need to read in the default values for the storey they are located on.
So in each object I need to INPUT to read in these values.
Here is the script for that.

rrr=REQUEST ("Name_of_plan", "", pname)
rrr=REQUEST ("Home_story", "", hsindex, hsname)
fspec="C:\Program Files\ArchiCAD 8.1\ArchiCAD Data Folder"+pname+"_BCA_window_default_settings.xls"
ch1 = open("data",fspec,"Separator='\t',Mode = WA")
in1 = INPUT (ch1, hsname + " - U_value", 1, U_value)
in2 = INPUT (ch1, hsname + " - SHGC", 1, SHGC)
in3 = INPUT (ch1, hsname + " - Shade o/hang", 1, shade_ohang)
in4 = INPUT (ch1, hsname + " - Shade height", 1, shade_hgt)

close ch1

PARAMETERS U_value = U_value
PARAMETERS SHGC = SHGC
PARAMETERS shade_ohang = shade_ohang
PARAMETERS shade_hgt = shade_hgt


The problem is the "hsname" variable seems to have no value when used in the INPUT command.
There was a discussion in another post on a different subject but also involed a problem with REQUEST.
http://archicad-talk.graphisoft.com/viewtopic.php?t=8856&start=10

Franks reply at one point was
F. wrote:
Most REQUESTs and GLOBALs, which refer to environment specific status of the object do not work in the dialogue box or the object editing window. That sometimes anoying, because a placed object or window does have this relations yet, but they are not available, when the script runs for the preview.

We had this with ZONE_RELATIONS a few weeks ago in the german talk, where one wanted to take over the zone number into an object, which was placed on the zone area. We did not get it to work, because in case PARAMETERS work, the REQUEST returned a zero-result.

The big question is how can I get the windows and doors to read values from the text file based on the storey name?
I want this to be automatic - I don't want to have to set a parameter in the door/window to say which storey it is in when I know it already recognizes this with the REQUEST function.
How do I get the home storey request to work with the INPUT command?

Any ideas appreciated.
Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
10 REPLIES 10
Frank Beister
Moderator
I don't think that it's a request problem, because the open, output and input commands work all the time. You can check by an text editor, if the values you entered in the objects on each story are written to file.

But your INPUT command seems to be wrong. You can not just substitute OUTPUT by INPUT. The commands for external file access are served by AddOns. They do the complete syntax check and return an error by a value as the the function result (n=INPUT() etc.). Because of this you might not have gotten an error. Have a look into the GDL manual to get the right syntax. You are using the DATA addon.
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
Barry Kelly
Moderator
F. wrote:
I don't think that it's a request problem, because the open, output and input commands work all the time. You can check by an text editor, if the values you entered in the objects on each story are written to file.

But your INPUT command seems to be wrong. You can not just substitute OUTPUT by INPUT. The commands for external file access are served by AddOns. They do the complete syntax check and return an error by a value as the the function result (n=INPUT() etc.). Because of this you might not have gotten an error. Have a look into the GDL manual to get the right syntax. You are using the DATA addon.
The INPUT statements are correct.
If I put all this script in the 2D script then it all works fine.
I get my return values for the INPUTS - I can check by adding them as TEXT2 in the object.

That's why I was not getting anything before as I was doing my INPUTS in the master script where of course the object does not recognize any storeys.

So the problem I now have is how do I get a value from the 2D script into the master or parameter script so I can set the parameters?
I need (or would really like) the user to be able to see these default values in the object (but as locked values) because I need to be able to over-ride them if necessary by allowing the user to unlock them and insert their own value.
But maybe only one of the four will change which is why I want the defaults there so all four values don't need to be entered.

Almost there.
Thanks,
Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Rob
Graphisoft
Graphisoft
Barry,

try to create the actual parameter named "hsname" in parameter list, place the request statement in the master script and write the code in the parameter script like this: PARAMETERS hsname=hsname.

One more think - the master script is always run no matter which window 2D or 3D you are in, e.g. when in the plan the master script is actually a part of the 2D script and same for 3D and/or parameter script.
::rk
Frank Beister
Moderator
The INPUT statements are correct.
I am surprised by this, because the syntax does not look like they should be. Can you send me an example PLA? (I send you a contact by PM, the opengdl - contact is broken a few days )

You are opening the file by "WO". This means all will be overwritten, each time the script runs. If you put it in master script, this could cause, that the last run of the script will have a context the request does not work indeed.

AFAIR does not work the HOME-STORY- REQUEST in settings dialog. So you will not be able to store the REQUEST-result into the parameter by PARAMETERS. This is the problem you quoted, we have found in the other request thread.

Another point is, that the file has to be created BEFORE any window script is run. This might cause problems too, because you can't influence the order of the objects to be recalculated.

EDIT:
I have to correct me. You are right, the syntax seems to be correct. I haven't understood, that you use the story name as part of the recordID, I thought you read all from file and separate it in the GDL code.
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
Barry Kelly
Moderator
Rob wrote:
Barry,

try to create the actual parameter named "hsname" in parameter list, place the request statement in the master script and write the code in the parameter script like this: PARAMETERS hsname=hsname.

One more think - the master script is always run no matter which window 2D or 3D you are in, e.g. when in the plan the master script is actually a part of the 2D script and same for 3D and/or parameter script.
Hi Rob,
I wish it worked like this but the REQUEST seems to be a strange beast.
Try this in the master script of an object with a parameter set up for "hsname".

rrr=REQUEST ("Home_story", "", hsindex, hsname)

PARAMETERS hsname=hsname
TEXT2 0,0, hsname


You will get a value for hsname and you will see the text on plan, but the parameter will not be set.
Exactly why I am not sure.
As Frank explained to me the master script is run a number of times and each time only the relavent 2D, 3D etc., commands are processed (If I understood correctly).
I still don't understand why if a variable has a value then why can't the parameter be set.
Unless at some stage in the process the master script is being run and the variable has no value so is being set to nothing - but then why does the text appear still?
I don't know, I'm a bit confused over all of this.
You would think it would work but it doesn't so I need to find a way around it.

Even saying -

newname = hsname
PARAMETERS newname = newname

still doesn't work.
Likewise I can't use the INPUT command in the master script as the field in the text file I am searching for is based on hsname.
In the 2D script it all works fine.
But then I can't set my retrieved inputs as parameters.

Seems to be a bit of a trap at the moment.

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Rob
Graphisoft
Graphisoft
Barry,

I just want to make sure...
have you placed the expresion PARAMETERS hsname=hsname in the parameter script window?


it works for me on v9 and v10 , attached image...
hsnamecode.jpg
::rk
Barry Kelly
Moderator
Rob wrote:
Barry,

I just want to make sure...
have you placed the expresion PARAMETERS hsname=hsname in the parameter script window?


it works for me on v9 and v10 , attached image...
I've tried in all the scripts.
Obviously a bug in V81.

Just checked in V9.0 which we aren't using but I got the other day.
And it works fine.

We have upgraded to V10 which will hopefully arrive soon.
I was hoping to jump straight to that version without installing V9.0 on all of our machines (69 licenses).

Now I just hope we can open our existing V81 files in V10 with no problems or I am stuck

I guess I will just have to wait and see.

Do you have V10 AUS already or were you a beta-tester

Thanks for your input.
I knew I should have checked in V90.
Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Barry Kelly
Moderator
F. wrote:
You are opening the file by "WO". This means all will be overwritten, each time the script runs. If you put it in master script, this could cause, that the last run of the script will have a context the request does not work indeed.
Yes I should be opening as read only.
I had just copied this from another script where I needed to input the value and then add to it and output it back to get a total value from a group of individual objects.
F. wrote:
AFAIR does not work the HOME-STORY- REQUEST in settings dialog. So you will not be able to store the REQUEST-result into the parameter by PARAMETERS. This is the problem you quoted, we have found in the other request thread.
Seems all my problems have been solved and it turns out to be a bug in V8.1
As Rob points out it works fine in later versions so I will just have to wait till V10 arrives.
I should have checked before as I have found other problems that don't work in V81 as they should but do in V90 (and hopefully V10).

Thanks for your help.
Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Rob
Graphisoft
Graphisoft
Do you have V10 AUS already or were you a beta-tester
no, I do not have v10AUS yet. yes, I am a beta fiddler...

and try to not use AC8.1 anymore it is a scary piece of work...
::rk