# Parametric Brick Wall and Screen — Grasshopper User Guide

This Grasshopper definition generates individual bricks for straight walls, curved walls, and openwork screens. It can build rectangular bricks or use a Rhino polysurface as a custom brick mold. The optional interlock mode is designed for the matching grooved brick profile and adjusts the spacing between courses so adjacent pieces can bear on one another.

## 1. Component setup

1. Open Rhino and Grasshopper. Use a **Python 3 Script** component in Rhino 8.
2. Open the component’s Script Editor and paste the contents of `pared_ladrillos_gh.py`.
3. Add the inputs listed below. Match the names exactly, including capitalization. Use **Item Access** unless the table specifies **List Access**.
4. Create three regular outputs named `bricks`, `count`, and `info`. The built-in `out` port is the Python console. Keep it separate from `bricks`.
5. Connect `bricks` to a **Brep** parameter and connect `info` to a **Panel**. The Panel shows how many bricks and courses were generated, or why generation stopped.
6. Use a Rhino document set to **meters** with the example values below. The script uses the document’s units directly, so convert the input values if you work in a different unit system.

## 2. Inputs

| Input | Type | Default | What it controls |
|---|---|---:|---|
| `L` | Number | `3.0` | Wall length. A connected `path` overrides it with the length of the guide measured in plan. |
| `H` | Number | `2.0` | Maximum wall height measured from the base. Standard mode can shorten the last course. Interlock mode keeps only full-height courses. |
| `T` | Number | `0.12` | Brick thickness before rotation or curve deformation. Along a guide, thickness extends to the left as you look from the start toward the end. Reverse the guide to switch sides. |
| `brick_L` | Number | `0.24` | Nominal length of one brick. With a custom mold, the script scales the mold along its X axis to fit each brick position. |
| `brick_H` | Number | `0.07` | Nominal height of one brick. With a custom mold, the script scales the mold along its Z axis. |
| `joint` | Number | `0.01` | Gap between bricks in the same course. In standard mode it also sets the vertical gap. In interlock mode the script calculates the vertical spacing from the grooved profile. |
| `offset` | Number, `0` to `1` | `0.5` | Shifts every other course by a fraction of one module, where a module is `brick_L + joint`. Use `0` for aligned joints and `0.5` for a half-module bond. Interlock always uses `0.5`. Keep the input within `0` to `1` because the script validates it before applying the override. |
| `plane` | Plane | World XY | Sets the origin and orientation when `path` is empty. Local X is the wall length, Y is the thickness, and Z is the height. |
| `run` | Boolean | `True` | Enables generation. Set it to `False` while changing inputs on a large definition. |
| `path` | Curve | Empty | A line or curve that defines the wall alignment. If the guide changes elevation, the script projects it onto a horizontal plane at its starting elevation. The projected guide must have a usable length. |
| `rotation` | Number, **List Access** | Empty (`0°`) | Rotates each brick around the vertical axis through its center. A single angle applies to all bricks. A flat list applies in brick output order and repeats when it runs out. |
| `brick_model` | Brep | Empty | A Rhino polysurface to copy and scale at every brick position. Orient the source with length along X, thickness along Y, and height along Z. With no mold connected, standard mode generates rectangular solids. |
| `interlock` | Boolean | `False` | Enables the half-module bond and calculated vertical spacing for the matching grooved mold. Requires `brick_model` and zero brick rotation. |

The first nine inputs, from `L` through `run`, must exist with those exact names. Set any unconnected inputs to optional so the component can use the defaults. The script also tolerates omitted `path`, `rotation`, `brick_model`, and `interlock` ports.

## 3. Operating modes

### Straight wall

Leave `path` empty and set `interlock` to `False`. Set `L`, `H`, and `T`, then adjust the brick dimensions, joint, and course offset. Use `plane` to position the wall. For a first test, use the defaults for a nominal **3 × 2 m** wall with a **120 mm** thickness and **10 mm** joints.

### Wall along a line or curve

Reference a line or curve from Rhino in a Grasshopper **Curve** parameter and connect it to `path`. A connected guide replaces `L` and `plane` for placement. In standard mode, each brick remains straight and is oriented to the tangent at its midpoint. Along tight curves or sharp corners, joints can vary and adjacent bricks can overlap. Inspect the preview when changing the guide, brick length, or wall thickness.

### Rotated brick screen

Set `interlock` to `False` and connect angles in degrees to `rotation`. Start with a single angle, such as `15`, then try a flat list such as `30, -30` for an alternating pattern. The sequence continues from one course to the next, so the starting angle of a new course depends on how many bricks were generated before it. Rotation keeps each brick’s center fixed. Check clearances and increase `joint` if the pieces intersect.

### Wall with a custom brick mold

Create or select the brick polysurface in Rhino. Reference it with a **Brep** parameter using **Set one Brep**, then connect it to `brick_model`. The script uses the mold’s world-axis bounding box and scales its length, thickness, and height independently to fit each brick position. In standard mode, edge pieces and the last course can be shorter or lower. A custom mold is compressed to fit these positions, while a rectangular brick is generated directly at the smaller dimensions.

### Interlocking wall with the grooved brick

1. Generate or reference the matching grooved brick from `ladrillo_acanalado_rhino.py` and connect it to `brick_model`. The interlock calculation assumes the original symmetric circular grooves, each with a depth of **18 mm** on a **70 mm** high mold, or the same depth-to-height ratio.
2. Set `interlock` to `True` and `rotation` to `0°`. The script uses a half-module shift regardless of the `offset` slider position.
3. Adjust `joint` to set the lateral gap. The gap must be smaller than `brick_L`. The script calculates the vertical pitch so that the ends of the upper pieces are positioned to meet the grooves of the neighboring course.
4. Use a straight alignment or connect a smooth curve to `path`. For a curved guide, the script builds the interlocking arrangement straight first, then bends all the pieces onto the same curve. This deforms the bricks and is intended to carry their contact points with them.
5. Inspect the contact and clearances in Rhino, especially at tight bends. The script checks whether bending creates invalid pieces or opens an originally closed solid. It does not measure the final contact area or test for collisions between pieces.

Interlock omits pieces that would need to be shortened at the wall ends or top. This preserves the groove profile but can leave stepped ends, an unused strip at the top, or a gap at the seam of a closed guide. The calculated spacing assumes the matching grooved profile and may give incorrect results with a differently shaped mold.

## 4. How the script works

| Stage | Behavior |
|---|---|
| Read inputs | The `value()` helper supplies numeric defaults for empty inputs and converts connected values to numbers. The script checks that dimensions are positive, the joint is nonnegative, and the offset is within range. |
| Prepare the guide | The script resolves Rhino geometry references, converts lines to curves, and projects nonhorizontal guides into plan when needed. It uses the resulting curve length to lay out the wall. |
| Calculate the bond | The script spaces bricks by `brick_L + joint` along each course. Standard courses are spaced vertically by `brick_H + joint`. Interlock calculates a smaller vertical pitch from the groove geometry. |
| Fit pieces to the wall | Standard mode fits pieces to the wall’s length and height limits. Interlock keeps full pieces. Courses are processed from bottom to top and bricks are processed along the wall or guide within each course. |
| Build and orient the geometry | Each position becomes a rectangular Brep or a scaled copy of the mold. Standard curved walls orient pieces at the local tangent. Curved interlock uses one common deformation across the whole arrangement. |
| Apply rotation | Angles are assigned in output order. Each brick rotates in place before it is added to the output list. |
| Return results | `bricks` contains the generated Breps, `count` gives the number of pieces, and `info` reports the number of pieces and nonempty courses or an error. The script stops when its estimate exceeds 50,000 pieces. |

## 5. Troubleshooting

| Symptom | What to check |
|---|---|
| `bricks` is empty and `info` says the interlock needs a mold | Add the `brick_model` input and connect the matching grooved Brep. In the current Grasshopper setup, this is the first issue to resolve before testing curved interlock. |
| The Brep parameter receives nothing | Check `info`, make sure `run` is enabled, and confirm that your Brep parameter is wired to the regular `bricks` output rather than the console port. |
| Connecting a guide stops generation | Confirm the Curve parameter contains a valid Rhino reference and that the guide has a nonzero length in plan. A purely vertical line collapses when projected. |
| The offset slider has no visible effect | With `interlock` enabled, the bond is fixed at `0.5`. Turn interlock off to adjust the offset. |
| Bricks intersect in a curved or rotated screen | Reduce the rotation, increase the lateral joint, or try a gentler curve. Recheck the result in plan and perspective. |
| Interlocking courses have gaps or overlap | Verify that the source mold matches the original symmetric groove proportions and that rotation is zero. Test a straight guide first to isolate issues caused by curve deformation. |
| `count` is positive but the wall is invisible | Check that preview is enabled for the Brep parameter and that the Rhino viewport is looking at the wall’s location. |
| Status messages appear in Spanish | The current script reports status and errors in Spanish. `ladrillos` means bricks, `hiladas` means courses, `junta` means joint, and `encastre` means interlock. |

Grasshopper displays the wall as a live preview. To create editable Rhino objects, right-click the downstream **Brep** parameter and select **Bake**. Baked bricks are a snapshot of the current result and do not update when the Grasshopper inputs change.