We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

Loop an object

Anonymous
Not applicable
Hi. I am trying to loop this Object. Can anybody pleas tell me in English how it is done. I can not seem to understand the Reference guide.
My goal is to have the Object to repeat it self and adjust the last one. it should stop and start over when it passes 900mm.
Thank you very mutch.
8 REPLIES 8
sinceV6
Advocate
Hi.
There are several things you would need to change:

In 2D, your hotspot is controlling the size of the rectangle. It should control the size of the object. You must calculate how many times your rectangle fits in the overall length, and then move your 2d script to a subroutine so you call it each time you need to draw it.

To LOOP it, you need a loop: a FOR, WHILE, Do WHILE, etc loop depends on your needs.

Comment out your 3D script, and put this in your 2D script, check how it works and continue from there:


hsid= 1


hsid=hsid+1 !Base
HOTSPOT2 0,0, hsid, A, 1  !<--- hotspot now controls A, not your other variable

hsid=hsid+1 !Move
HOTSPOT2 A,0, hsid, A, 2  !<--- hotspot now controls A, not your other variable

hsid=hsid+1 !Vector
HOTSPOT2 -1,0, hsid, A, 3  !<--- hotspot now controls A, not your other variable

line2 0,0, a,0  !<--- so you can see the overall size of the object

!HOW MANY RECTANGLES??? !<--- variable to store how many times to repeat subroutine
howMany = INT(A/bredde) !<--- integer!!!

FOR i=1 TO howMany			!<--- this is one LOOP you can use. Check documentation.
	GOSUB "RECTANGLE SUB"   !<--- calling the subroutine
	ADD2 bredde,0			 !<--- moving the origin to draw next iteration, size from your parameter
NEXT i

DEL NSP   !<--- return origin to zero

END !<--- END of the 2D script, so you can use subroutines


"RECTANGLE SUB":  !<--- you call this each loop
rect2 0,0,bredde,dybde
RETURN  !<--- return from subroutine
Hope this helps. Use it as a starting point. You would need extra code to make the last part adjust to the remaining length of the object; and you would need to apply the same principle to your 3D script.

Best regards.
Anonymous
Not applicable
Thank you Sir.
That was very helpful Can you please explain what i should do in the 3d script. where should i put the loop? Comment out your 3D script?
Thank you very mutch.
sinceV6
Advocate
You're welcome.

Like I said, apply the same structure. Once you understand how the 2D script works, you should be able to write the 3D script. I would place each part of the 3D script that builds something inside a subroutine, and call it each iteration.

I forgot to explain that in the 2D script, the "RECT2" part could be directly inside the FOR loop (instead of GOSUB, you could write RECT2 code, and it will repeat each loop); but using subroutines gives your code a better structure and it is easier to debug, or at least that's what I try to do.

Comment out your 3D script meant that you should make all your 3D script a comment, by selecting it all and use the comment button at the very top of the window to apply it to the code, so you could first work in the 2D script to understand it and just to avoid any conflict with the changes.

Best regards.
Anonymous
Not applicable
You are AWESOM! Thank you. it Works.
In the schedules it says that it is one Object even though it is many Fields. Is it possible to have AC Count the Fields in the schedueles?
and how can i control each field with boleen?
David Maudlin
Rockstar
omar wrote:
In the schedules it says that it is one Object even though it is many Fields. Is it possible to have AC Count the Fields in the schedueles?
One option is to create a new parameter that is equal to the "howMany" integer (PARAMETERS command), then adding this parameter as part of your schedule.

David
David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC27 USA • iMac 27" 4.0GHz Quad-core i7 OSX11 | 24 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14
Anonymous
Not applicable
Thank you David. Can you please explain. i cant get it to work.
David Maudlin
Rockstar
omar:

Add a new parameter "Fields_No"
In the Parameters Script or Master Script add the command:
Parameters Fields_No = howMany
Now your object will display a parameter with the number of units (Fields) generated. In the In the Interactive Schedule use the Add command in the Fields panel to add this parameter to the Schedule Fields. This parameter can now be used by the Interactive Schedule to count and sum the number of units generated (rather than number of objects) generated.

David
David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC27 USA • iMac 27" 4.0GHz Quad-core i7 OSX11 | 24 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14
Anonymous
Not applicable
Thank you.