We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-04-03 05:53 PM - last edited on 2024-09-24 10:21 AM by Doreena Deng
Hi, I am getting trying to get into GDL and wanted to try and create a simple object of a rectangle with an adjustable amount of divisions and border. I attempted to reverse engineer the "DET_Layout_Template" object that comes with archicad but I am having trouble getting my For To Next command to actually repeat and move.
FOR i = 1 to divx STEP 1
GOSUB 3050 !Column of boxes
ADD2 lw,0
NEXT i
END
!=======================================
3050:
FOR i = 1 TO divy STEP 1
POLY2_B 5, 3, flpen, flbkpen,
0,0,1,
lw,0,1,
lw,lh,1,
0,lh,1,
0,0,1
ADD2 0, lh+munt
NEXT i
RETURN
This is what I have for my script.
add2 -ModW,0
for i=1 to MN2 step 1
gosub 3050 ! display column of boxes
add2 -ModW - psGapX ,0 ! advance to next column position
next i
end
! ========= Subroutine to display column of module-sized boxs
3050:
mnh=mn1+1
repeat
pen 99
hotspot2 0, 0
hotspot2 ModW, 0
hotspot2 0, ModH
hotspot2 ModW ,ModH
pen 95
rect2 0, 0, ModW, ModH
! Hotlines on rectangle for easier snapping
hotline2 0, 0, ModW, 0
hotline2 ModW, 0, ModW, ModH
hotline2 ModW, ModH, 0, ModH
hotline2 0, ModH, 0, 0
pen 92
line2 0, 0, ModW, ModH
line2 0, ModH, ModW,0
add2 0, ModH + psGapY
mnh = mnh-1
until mnh = 1
del mn1
RETURN
This is what is in the DET_Layout_Template object, I can't for the life of me figure out how this one gets the subroutine to "advance to the next column position"
Solved! Go to Solution.
2024-05-04 04:08 PM
You cannot use the same loop counter like "i" in nested loops more than 1 time.
If you start your first loop with the counter "i" and then jump to the subroutine with a second loop, you should use there another counter, e.g. "j", otherwise you will get an error message or an infinty loop.
That's why I always use in a loop within a Subroutine double characters as counter, like ii and jj (or i_1 and j_1), and in one subroutine deeper iii and jjj and so on.
2024-04-08 01:23 PM
Hi,
you need to DEL the transformations done in Y direction to start at the same Y coordinate in the next X column.
2024-05-04 01:12 AM
Is there also the problem that "i" is being used for both of the loop counters and one is overwriting the other? If you change the other to "j" or whatever does it then work?
2024-05-04 04:08 PM
You cannot use the same loop counter like "i" in nested loops more than 1 time.
If you start your first loop with the counter "i" and then jump to the subroutine with a second loop, you should use there another counter, e.g. "j", otherwise you will get an error message or an infinty loop.
That's why I always use in a loop within a Subroutine double characters as counter, like ii and jj (or i_1 and j_1), and in one subroutine deeper iii and jjj and so on.