BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

? on For Next Loops

Anonymous
Not applicable
222: !BRICK TIES

FOR dist=0 TO 30' STEP brick_tie
ADDx dist
GOSUB 111

NEXT dist

RETURN

Will this work in an object? It's just putting 1 in and that's it. The brick_tie is a parameter for a length. GOSUB 111 is the actual lines for the brick tie.

Thanks for any help,
Michele
17 REPLIES 17
Anonymous
Not applicable
I forgot to mention this is in the 2D script window - It's not a 3D object only 2D.

Thanks,
Michele
Anonymous
Not applicable
Michele,
It should work.
Why don't you try it and see.
Del the addx transformations
before return.
Peter Devlin
Anonymous
Not applicable
I think there was an error in the GOSUB routine (along w/ other errors) but it's working now. A little trial & error goes a long way.

Thanks,
Michele
Anonymous
Not applicable
It seems that all I do is a lot of trial and error
Peter Devlin
TomWaltz
Participant
Probably not. For/Next works best with integer counters. I am betting you could end up with fractions/decimals pretty easily with this.

I would go with more of a WHILE/DO. like

WHILE dist < 30'-0" DO....

dist = dist + bricktie
ENDWHILE
Tom Waltz
Anonymous
Not applicable
Hello Tom,
Could you tell us what happens if
you end up with fractions/decimals.
Until two days ago I thought
for loops could only work with integers
but now I'm not so sure.
Thanks,
Peter Devlin
TomWaltz
Participant
I couldn't say for sure with Archicad, but most programming books I've ever seen tell you to avoid it since you cannot predict how the program will respond.
Tom Waltz
Anonymous
Not applicable
Hello Tom,
That was my impression also until, as I said, two days ago.
You mentioned once that you were studying C++.
Does the C++ for loop have the "step" part like GDL ?
It occurs to me that maybe some computer languages
may not have "step" and in that case only integers can be used.
I did a little test using the piece of code using a for loop on
page 1.26 of the GDL Cookbook 3. I tried to force the for loop
to use fractional values and calculate fractional values and
it seemed like there was no problem. The result were always
what you would expect.
Just a few thoughts,
Peter Devlin
TomWaltz
Participant
Peter wrote:
Hello Tom,
That was my impression also until, as I said, two days ago.
You mentioned once that you were studying C++.
Does the C++ for loop have the "step" part like GDL ?
It occurs to me that maybe some computer languages
may not have "step" and in that case only integers can be used.
I did a little test using the piece of code using a for loop on
page 1.26 of the GDL Cookbook 3. I tried to force the for loop
to use fractional values and calculate fractional values and
it seemed like there was no problem. The result were always
what you would expect.
Just a few thoughts,
Peter Devlin
Honestly, I've not used any C++ for almost a year... I think there was, but I cannot say for sure from memory and I'm too lazy to look it up right now 🙂
Tom Waltz
Learn and get certified!