GDL
About building parametric objects with GDL.
SOLVED!

Parameter buffer and Loops

MF BIM
Booster

Hello,

 

I'd like to know how to improve my use of the Parameter buffer when it comes to loops because I have a loop that create a simple stack of prisms :

 

for N = 1 to 4
	put		0, 0, 15,
			1, 0, 15,
			1, 1, 15,		
			0, 1, 15,	
			0, 0, 1
	prism_	nsp/3, 0.5, get(nsp)
	addz	0.5
next N
del 4

 

 

I feel this code is not good as I populate and clear the stack with each loop rather than populating it once, looping the geometry and clearing the stack at the end. I would like to make it better but the following snippet doesn't work :

 

 

put	0, 0, 15,
	1, 0, 15,
	1, 1, 15,		
	0, 1, 15,	
	0, 0, 1
for N = 1 to 4
	prism_	nsp/3, 0.5, use(nsp)
	addz	0.5
next N
del 4
get(nsp) ! Clearing the stack that way after the loop doesn't work

 

 

 Is there a way to clear the parameter buffer without having to use get() in a command ? Or am I reduced to do this :

 

 

put	0, 0, 15,
	1, 0, 15,
	1, 1, 15,		
	0, 1, 15,	
	0, 0, 1
for N = 1 to 4-1
	prism_	nsp/3, 0.5, use(nsp)
	addz	0.5
next N
prism_	nsp/3, 0.5, get(nsp)
del 3
get(nsp) 

 

 

Looks less readable but seems to be the only solution ?

https://mfbim.fr | https://youtube.com/@mfbim
AC21 FRA 3005 - AC24 FRA 7600 - AC26 FRA 4027 | MacBook M1 Pro
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
kuvbur
Enthusiast

Try to use

 

if NSP>0 then ttt = max(get(NSP))

Final code:

n_prism = 4

put	0, 0, 15
put	1, 0, 15
put	1, 1, 15	
put	0, 1, 15
put	0, 0, 1
for N = 1 to n_prism
	prism_	nsp/3, 0.5, use(nsp)
	addz	0.5
next N
del n_prism
if nsp>0 then ttt = max(get(nsp))

 

Structural engineer, developer of free addon for sync GDL param and properties

View solution in original post

5 REPLIES 5
Solution
kuvbur
Enthusiast

Try to use

 

if NSP>0 then ttt = max(get(NSP))

Final code:

n_prism = 4

put	0, 0, 15
put	1, 0, 15
put	1, 1, 15	
put	0, 1, 15
put	0, 0, 1
for N = 1 to n_prism
	prism_	nsp/3, 0.5, use(nsp)
	addz	0.5
next N
del n_prism
if nsp>0 then ttt = max(get(nsp))

 

Structural engineer, developer of free addon for sync GDL param and properties

Thanks, it worked 👍

https://mfbim.fr | https://youtube.com/@mfbim
AC21 FRA 3005 - AC24 FRA 7600 - AC26 FRA 4027 | MacBook M1 Pro
yongler
Booster

The last get (nsp) is not needed because it does not perform any operations and only extracts data, resulting in a program error.

If you only ever 'USE' the PUT stack, then the stack will remain populated.

The last 'GET' just clears the stack so you can use PUT again later if you need to.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

It should be possible to just use GET(NSP) to Empty the stack. While it is not, Thank you for this solution.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!