> For the complete documentation index, see [llms.txt](https://docs.openbrim.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openbrim.org/developers/paramml-developer-guide/core-objects/base-core-object/repeat.md).

# Repeat

Sometimes a certain part of an object's code may need to be repeated many times. Even the number of repetitions may be required to be determined by the user. In short, the **Repeat Object** is used to clone a series of objects multiple times.

Many structures consist of repetitions of structural components. For example;\
Multiple beams with different bracing locations in a bridge.\
Multiple stem rigidity bars in a bridge.\
Multiple panels for one tower.\
Multiple floors for one building.\
A previously defined content can be placed in the Repeat Object and cloned and positioned at certain geometric intervals. Any content inside the Repeat object is repeated as many times as the specified parameter.

All Repeat Objects must contain the following parameters:

* S (start)
* E (end)
* I (increment)
* CTRL (control parameter)

**Syntax**

```
...
...
<O T="Repeat"
...
</O>
```

**Example**

```xml
<O N="Replicate" T="Project" Category="Core Objects">
    <!-- created by ParamML Examples on 26.01.2023 -->
    <O N="Recap" T="Repeat" S="0" E="3" I="1" CTRL="j" j="0">
        <P N="Result" V="pow(3,j)" />
    </O>
    <O T="Design Code">
        <P N="RecapObjectList" V="Recap" />
        <P N="RecapResult0" V="Recap[0].Result" />
        <P N="RecapResult1" V="Recap[1].Result" />
        <P N="RecapResult2" V="Recap[2].Result" />
        <P N="RecapResult3" V="Recap[3].Result" />
        <!-- -l- -->
        <P N="Result0" V="pow(3,0)" />
        <P N="Result1" V="pow(3,1)" />
        <P N="Result2" V="pow(3,2)" />
        <P N="Result3" V="pow(3,3)" />
    </O>
</O>
```

The above codes give exactly the same results as below. ![](https://openbrim.atlassian.net/wiki/download/attachments/2155642883/image-20230126-092233.png?api=v2) To view this example in the library, see (<https://openbrim.org/platform/?application=inc&author=ParamML_Examples_OpenBrIM+Platform&obj=objidywfidyhjvzme5h9q6soyns> )

**Example:**

```xml
<O T="Repeat" S="0" E="4" I="1" CTRL="index" index="0">
        <O N="Rectangular Column" T="Line">
            <P N="Guard" V="type .EQ. RECTANGULAR" />
            <O T="Point" X="index * 15" Y="0" Z="0" />
            <O T="Point" X="index * 15" Y="0" Z="height" />
            <O N="Rectangular" T="Section">
                <O T="Shape">
                    <O T="Point" X="-width/2" Y="-depth/2" Z="0" />
                    <O T="Point" X="-width/2" Y="depth/2" Z="0" />
                    <O T="Point" X="width/2" Y="depth/2" Z="0" />
                    <O T="Point" X="width/2" Y="-depth/2" Z="0" />
                </O>
            </O>
        </O>
    </O>
</O>
```

In the example provided, a 3D column object of type line is created and placed within a Repeat loop. The loop, with a starting number of 0, an ending number of 4, and incrementing by one each time, iterates 5 times (the end value is included: index = 0, 1, 2, 3, 4), resulting in the creation of 5 identical column objects. This process results in the following system as output. ![](https://openbrim.atlassian.net/wiki/download/attachments/2155642883/image-20230126-114616.png?api=v2) To view this example in the library, see (<https://openbrim.org/platform/?application=inc&author=ParamML_Examples_OpenBrIM+Platform&folder=Core+Objects&obj=objid77165d5s6l3r54bcc8luz> )

The Repeat Object also allows for counting elements in a list and separating them as needed. This can be useful in situations where specific elements within the list need to be grouped or separated based on certain criteria.

**Example:**

```xml
<O N="Repeat_in_repeat_Object" T="Project">
    <!-- created by ParamML Examples on 26.01.2023 -->
    <O N="Recap1" T="Repeat" S="0" E="3" I="1" CTRL="i" i="0">
        <O N="Recap" T="Repeat" S="0" E="4" I="1" CTRL="j" j="0">
            <O N="Circle" T="Volume" Y="20*i" X="20*j">
                <O T="Circle" Radius="10" Z="0" />
                <O T="Circle" Radius="10" Z="10" />
            </O>
        </O>
    </O>
</O>
```

In the above example, there are two nested repeat objects. In these objects, when it gets i=0 first, the object inside will repeat from j=0 to j=4 5 times and clone the 3D object within 5 of them.

Later, when the inside repetitions are completed, i = 1 will be and the inside object will be 5 again and will be created once.

Thus, as each i value increases, the j value will increase 5 times. This will continue until the outermost repeat count is completed and the following 3D object will be created. ![](https://openbrim.atlassian.net/wiki/download/attachments/2155642883/image-20230126-121323.png?api=v2) To view this example in the library, see (<https://openbrim.org/platform/?application=inc&author=ParamML_Examples_OpenBrIM+Platform&folder=Core+Objects&obj=objidr5mrcuyfnw8mxik04obc>)

ParamML is a programming language that employs lazy evaluation (<https://en.wikipedia.org/wiki/Lazy_evaluation> ), where each parameter is only computed when it is called. Unlike sequential programming (e.g., <http://VB.NET> ), where each line is executed one by one, ParamML doesn't compute every parameter upfront. However, a drawback is that if a parameter is called a thousand times, it needs to be computed a thousand times, which can be a significant performance issue.

To address this problem, caching is used (<https://en.wikipedia.org/wiki/Cache_(computing)> ). Inside a "Repeat", each iteration is computed with its own cache. Earlier versions threw that cache away after every iteration, so a value used inside the loop was recomputed for every index unless it was listed in "StaticParams", whose values were computed once and kept for all iterations.

The engine now does this automatically: any value read inside a Repeat that does not depend on the control variable is computed once and reused by every iteration. "StaticParams" is therefore no longer needed and is ignored; objects that still list it work the same. The example below shows the old usage.

**Example:**

```
<O N="StaticParamsObject1" T="Project" Category="Core Objects">
    <!-- created by ParamML Examples on 8/29/2023 -->
    <P N="StaticParameters" V="10" />
    <O T="Repeat" S="0" E="2" I="1" CTRL="index" index="0" StaticParams="[StaticParameters]">
        <P N="width" V="StaticParameters" />
        <P N="depth" V="StaticParameters" />
        <O N="Rectangular Column" T="Line">
            <O T="Point" X="index * 15" Y="0" Z="0" />
            <O T="Point" X="index * 15" Y="0" Z="width" />
            <O N="Rectangular" T="Section">
                <O T="Shape">
                    <O T="Point" X="-width/2" Y="-depth/2" Z="0" />
                    <O T="Point" X="-width/2" Y="depth/2" Z="0" />
                    <O T="Point" X="width/2" Y="depth/2" Z="0" />
                    <O T="Point" X="width/2" Y="-depth/2" Z="0" />
                </O>
            </O>
        </O>
    </O>
</O>
```

To view this example in the library, see (<https://openbrim.org/platform/?application=inc&author=ParamML_Examples_OpenBrIM+Platform&obj=objidro1flg1c11lprm05wr6kzo> )

### Parameters of Repeat Object

| **Label**        | **Mandatory** | **Name and Type Attributes** | **Default Description and Value Attributes**                                                                            | **Other Attributes** |
| ---------------- | ------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------- | -------------------- |
| Control Variable | Yes           | N="CTRL" T="Text"            | D="Control Variable: The name of the variable that holds the repeat number as the contained objects repeated."V="index" | Role="Input"         |
| Start            | Yes           | N="S"                        | D="Start: Starting repeat number (default 0)" V="0"                                                                     | Role="Input"         |
| End              | Yes           | N="E"                        | D="End: Ending repeat number (default 9)"V="9"                                                                          | Role="Input"         |
| Increment        |               |                              |                                                                                                                         |                      |

(Each Step) | Yes | N="I" | D="Increment: Increment used to go from start to end (default 1)"V="1" | Role="Input" | | StaticParams | No | N=”StaticParams” | D=”Parameter list which are used in repeat iterations but no need to calculate at each step”. Ignored now: values that do not depend on the control variable are reused automatically. | Role="Input" |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.openbrim.org/developers/paramml-developer-guide/core-objects/base-core-object/repeat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
