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

Subroutine with variables

Anonymous
Not applicable
Hi All,
I am trying to work out if I can use the same subroutine (I hope Im using the right terminology) with different variables within an object.
I am using this for a reasonably complex custom door for my office, but I will give a basic example below what I mean

!block1

xx1 = 1
yy1 = 1
zz1 = 1

gosub 200:

!block2
xx1 = 2
yy1 = 2
zz1 = 2

gosub 200:


200:
block xx1,yy1,zz1
add xx1,0,0

I understand this is a nasty script as an example, but is there a way I can get this concept to work?

Thanks
Tom
3 REPLIES 3
Karl Ottenstein
Moderator
Yes, that's how you would do it... assuming there was a way of getting to block2 (block1 and block2 might be the branches of an if-then-else, for example) and that there is a return after the 200: sub code.

You can do a similar thing calling macros, which are separate GDL objects rather than in-line code as in a gosub. With macros, you give the parameter values in the call statement.
One of the forum moderators
AC 28 USA and earlier   •   macOS Sequoia 15.2, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
Thanks Karl,
Im a bit new to this subroutine idea.
My current door script is huge and I need to simplify it.
Macros seem pretty useful

Currently trying to investigate macros and struggling trying to find simple examples.

Does anyone have a basic example I could use?
Anonymous
Not applicable
OK, didn't realise a macro is a separate GDL part
I have created a test

!TestMacro 3D GDL Script
block xx1,yy1,zz1
add xx1,0,0

!Main Object 3D GDL Script
call "testMacro" parameters xx1=1, yy1=1, zz1=1
addx 1
call "testMacro" parameters xx1=2, yy1=2, zz1=2


Works a treat. Now I just need to use this concept in reality.

Thanks Karl