# Joined BReps Indices

**URL:** <https://discourse.mcneel.com/t/joined-breps-indices/169081>\
**Category:** Grasshopper\
**Tags:** windows, mac\
**Created:** [November 13, 2023, 1:17pm UTC](https://discourse.mcneel.com/t/joined-breps-indices/169081 "2023-11-13T13:17:15Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![dfytz1](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dfytz1/32/478701_2.png) [@dfytz1](https://discourse.mcneel.com/u/dfytz1)\
**Post date:** [February 5, 2026, 11:08pm UTC](https://discourse.mcneel.com/t/joined-breps-indices/169081/6 "2026-02-05T23:08:56Z")

</div>

if anyone needs join brep component that outputs indices of joined breps, here it is:

[JoinBrepsIndex.gh](https://discourse.mcneel.com/uploads/short-url/7URM49DfV0jm0TzC57J3W0ZJ3S4.gh) (13.5 KB)

rhinocommon method  
Brep JoinBreps(IEnumerable brepsToJoin, System.Double tolerance, System.Double angleTolerance, out List\<int\> indexMap)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/4/9/5/4954028cf9f80df61740868798f246abbc3f877d.jpeg)

```auto
using System;

using System.Collections.Generic;

using Rhino;

using Rhino.Geometry;

using Grasshopper;

using Grasshopper.Kernel.Data;

using Grasshopper.Kernel.Types;

public class Script_Instance : GH_ScriptInstance

{

private void RunScript(

        DataTree<Brep> breps,

double tolerance,

double angleTolerance,

ref object JoinedBreps,

ref object IndexMap)

  {

    DataTree<Brep> joinedTree = new DataTree<Brep>();

    DataTree<int> indexMapTree = new DataTree<int>();

if (tolerance <= 0)

    {

      tolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance * 2.1;

    }

if (angleTolerance <= 0)

    {

      angleTolerance = RhinoDoc.ActiveDoc.ModelAngleToleranceRadians;

    }

for (int bi = 0; bi < breps.BranchCount; bi++)

    {

      GH_Path path = breps.Path(bi);

      List<Brep> branch = breps.Branch(bi);

if (branch == null || branch.Count == 0) continue;

      List<int[]> idxMap;

      Brep[] joined = Brep.JoinBreps(branch, tolerance, angleTolerance, out idxMap);

if (joined != null && joined.Length > 0)

      {

if (idxMap != null && idxMap.Count == joined.Length)

        {

for (int j = 0; j < joined.Length; j++)

          {

            GH_Path resPath = new GH_Path(path).AppendElement(j);

            joinedTree.Add(joined[j], resPath);

int[] indices = idxMap[j];

if (indices != null && indices.Length > 0)

            {

foreach (int k in indices)

              {

                indexMapTree.Add(k, resPath);

              }

            }

          }

        }

else

        {

for (int j = 0; j < joined.Length; j++)

          {

            GH_Path resPath = new GH_Path(path).AppendElement(j);

            joinedTree.Add(joined[j], resPath);

            indexMapTree.Add(j, resPath);

          }

        }

      }

else

      {

for (int i = 0; i < branch.Count; i++)

        {

if (branch[i] == null) continue;

          GH_Path resPath = new GH_Path(path).AppendElement(i);

          joinedTree.Add(branch[i], resPath);

          indexMapTree.Add(i, resPath);

        }

      }

    }

    JoinedBreps = joinedTree;

    IndexMap = indexMapTree;

  }

}

```

---

_[View the full topic](https://discourse.mcneel.com/t/joined-breps-indices/169081)._
