Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

RETURNED_PARAMETERS

dushyant
Booster
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

Podolsky
Newcomer
As you described, in another scripts this method is working. Try to search error in your macro. The error can be the reason why macro is not passing parameter. This the most annoying part in programming. Sometimes it can be some silly misspelling, that ruined the whole script.

dushyant
Booster
I checked all scripts, and there's no error prompted...

Podolsky
Newcomer
Publish your objects here - maybe someone will figure out where is the problem.

Barry Kelly
Moderator
dushyant wrote:
Then if I try, say
PRINT param1
it gives an error: "Unitialised variable"

Uninitialised variable just means it does not know what type of variable it is, number, string, etc.

Try adding ...

param1 = 0

or

param1 = "" (if it is a string)

Before the CALL command.

That way you are initialising the parameter before you use it.
I think also if you set the parameter in the parameter list of your parent object, that will do the same thing.


Barry.

One of the forum moderators.
Versions 6.5 to 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

dushyant
Booster
Barry,

Initialising the variable before the macro call does avoid that error of 'unitialised variable'. But then the value is still not changed.. meaning the macro is not returning it perhaps.

Yes, I had set the parameter in the parent object same as the RETURNED_PARAMETERS. Since it didn't work, I removed them to check if that was clashing with it.

Anyway, I'll check the macro object again.

dushyant
Booster
By the way, where do you normally place the CALL in the parent object?

The object I'm calling is actually a chair so I am calling it in the 3D script. And since I need the dimensions, I am returning the parameters in the macro from the Parameter script.

Does the placement of these in a particular script in both the parent & macro affect in anyway?

dushyant
Booster
I just tried with another test object as macro, and returned a value from it in the Parameter script. Then I called it in the Parameter script of the caller and its returned-params are successfully received.
But when I called the same macro in the 3D script, the returned params are not received it seems..

So again, I would like to know if it matters from which script we return the params in the macro and in which script we call it in the caller.

Barry Kelly
Moderator
If you are looking at setting parameter values, then I would CALL in the master or parameter script.
Ideally master - then all scripts will have access to this returned parameter value.
If you CALL in the 3D script, that parameter value can only be used in the 3D script.
At least that is my understanding of how it works.

Barry.

One of the forum moderators.
Versions 6.5 to 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

dushyant
Booster
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.

A_ Smith
Contributor
have you tried to look up AC example? They even have there object available for downloading
AC 22, 24 | Win 10

dushyant
Booster
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 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

dushyant
Booster
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
Newcomer
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
Booster
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 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

dushyant
Booster
Yes, got it. I'm not returning params from the 3D script now.
Thanks Barry.

Podolsky
Newcomer
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
Booster
Thanks for sharing that Podolsky!

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!