We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

GDL
About building parametric objects with GDL.

RETURNED_PARAMETERS

dushyant
Enthusiast
Hi

I'm trying to return some parameters from an object called in the parent object. I have placed the parameter names after the 'END' in the parameter script. In the caller, I'm doing as:
CALL 'childObject' PARAMETERS RETURNED_PARAMETERS param1
Then if I try, say
PRINT param1
it gives an error: "Unitialised variable"

I tried calling the object in the 3D script, Master script, and the Parameter script, and get the same error.

How do I access the returned parameter? I have tried in a similar way for another set of objects calling another macro, and it worked there. Don't understand what's wrong here..

Thanks
23 REPLIES 23
A_ Smith
Expert
have you tried to look up AC example? They even have there object available for downloading
AC 22, 24 | Win 10
dushyant
Enthusiast
A. wrote:
have you tried to look up AC example? They even have there object available for downloading
A. Smith, I had referred that page, but didn't download the example. I'll check it out.
Barry Kelly
Moderator
dushyant wrote:
Ok Barry.

So far I observed it just does not retrieve the returned parameters in the 3D script. Anyone, please let me know if it is possible to get the returned parameters from a macro called in the 3D script.

It does work - I just tested it.
So long as it is an actual parameter in the parameter list of the CALLed macro, and you have an ... END parameter_name ... in the 3D script.

But be careful, as you are returning the value of that parameter as it is in the 3D script.
i.e. you can change its value in the 3D script of the macro and it will return that value.
But the value in the 3D script is not necessarily the value of that parameter in the parameter list of the macro - you can not set that from the 3D script - only override it.
Changing the value of a parameter in the 3D script will not affect the 2D script

So if you are using the macro to calculate a parameter value - that is best done in the master script.
Both the CALL and the parameter calculations that is.


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
dushyant
Enthusiast
Barry,
Thanks for the info.
So to get the returned parameters in the 3D script, the macro must return it from its 3D script.
Podolsky
Ace
Upload your problematic script here - give pips chance to take a look. Maybe you do some logical mistake - and getting troubles, don't understand something in GDL structure... You will save a lot of your time by showing your script. Otherwise I'm out of this conversation.
dushyant
Enthusiast
Podolsky,

I had managed it, by returning params from the Parameter script of the macro, and retrieving them in the caller's Parameter script and setting callers params, when I used in the 3D.

Thanks all for your help!
Barry Kelly
Moderator
dushyant wrote:
So to get the returned parameters in the 3D script, the macro must return it from its 3D script.
Yes, but as I say be careful.
If you return a parameter value in the 3D script, you can only use it in the 3D script of the parent object.
It will not be available in the 2D script and you can not set the actual value of the parameter in the parameter list (i.e. PARAMETERS param_1 = param_1 ... only works in the master or parameter scripts).

Return a parameter in the master script and it is available for all of the other scripts in the parent object.

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
dushyant
Enthusiast
Yes, got it. I'm not returning params from the 3D script now.
Thanks Barry.
Podolsky
Ace
The best way to handle returned parameters routine is:

1. Make all necessary calculations / formulas in master script and define all variables (arrays) there.
2. Finish 2D, 3D, UI and parameter scripts with END and list of returned parameters - especially if this macro can be used multiply times with different objects.
3. In parameter script try to avoid using any mathematical calculations in command PARAMETERS. For example in parameter script instead of using PARAMETERS A=B+C, move A=B+C into master script and leave in parameter script only PARAMETERS A=A. Use mathematical computations in PARAMETER only if it happens in case of GLOB_MODPAR_NAME='something'.

Another good practise to get good working library of macros/objects is to start development from one object with core features. After save a copy of it, delete all scripts (keeping the same parameters) and make macro requests to the first object. Add additional parameters and infill it with scripts, adding to that secondary features. Make copy again and repeat steps as with first copy.
Then let say your third object will be visible for ArchiCAD and two previous non-placeable macros.

Let say I have such a matrioshka of macros: first macro is finding the path of curve, draw the lines, arches and hotspots in 2D and 3D space. Second macro is building 3D body based on first defined curve. Setting pens and materials. Third object - visible to user, controlling different parameters entered by user in UI.
dushyant
Enthusiast
Thanks for sharing that Podolsky!