# How to acces an CurveArrays?

**URL:** <https://forum.dynamobim.com/t/how-to-acces-an-curvearrays/95490>\
**Category:** Developers\
**Created:** [November 14, 2023, 9:39am UTC](https://forum.dynamobim.com/t/how-to-acces-an-curvearrays/95490 "2023-11-14T09:39:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [November 14, 2023, 9:39am UTC](https://forum.dynamobim.com/t/how-to-acces-an-curvearrays/95490/1 "2023-11-14T09:39:49Z")

</div>

Hello,

for any reason, my roof worklines apear as modelines how can i access them correctly  
here just array only:

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/5/e55daee8d4c966ef99c6a7a8879017c950497957.png)

```auto
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#functions
def tolist(x):
    if hasattr(x,' __iter__'): return x
    else: return [x]

#collector
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Roofs)
all_Roofs = tolist(collector.WhereElementIsNotElementType().ToElements())

profiles = [i.GetProfiles() for i in all_Roofs]

curves = [c.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble() for c in profiles]

OUT = all_Roofs, profiles, curves

```

KR

Andreas  
 ![2023-11-14_10h34_24](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/4/a410b941d13dff9db17081cfb914947a5321550c.png)

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [November 14, 2023, 9:48am UTC](https://forum.dynamobim.com/t/how-to-acces-an-curvearrays/95490/2 "2023-11-14T09:48:07Z")

</div>

The GetProfiles() method returns a ModelCurveArrArray which you will have to iterate through

Try this line  
`curves = [c.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble() for arr in profiles for c in arr]`

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [November 14, 2023, 2:50pm UTC](https://forum.dynamobim.com/t/how-to-acces-an-curvearrays/95490/3 "2023-11-14T14:50:07Z")

</div>

> [@Mike.Buttery](#):
>
> curves = [c.get\_Parameter(BuiltInParameter.CURVE\_ELEM\_LENGTH).AsDouble() for arr in profiles for c in arr]

![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/6/064e4284b90e363dfbb86bede7afca959667a7bf.png)

```auto
def tolist(x):
    if hasattr(x,' __iter__'): return x
    else: return [x]

#collector
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Roofs)
all_Roofs = tolist(collector.WhereElementIsNotElementType().ToElements())

profiles = [i.GetProfiles() for i in all_Roofs]

curves = [c.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble() for arr in profiles for c in arr]

#curves = [c.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH).AsDouble() for c in profiles]

OUT = all_Roofs, profiles, curves

```

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [November 14, 2023, 11:22pm UTC](https://forum.dynamobim.com/t/how-to-acces-an-curvearrays/95490/4 "2023-11-14T23:22:14Z")

</div>

This is like _Inception_ or perhaps _ModelCurveArrays_ all the way down. I think the better way to try this is to use other methods to get to the geometry.  
Add a function. This is not the way I would do it with pure python, however this handles the .NET objects better

```python
def flatten(x):
    try:
        return [a for i in x for a in flatten(i)]
    except:
        return [x]

```

Your collector is assuming FootPrintRoof types - perhaps make it explicit

```python
roofs = (
    FilteredElementCollector(doc)
    .OfClass(FootPrintRoof)
    .WhereElementIsNotElementType()
    .ToElements()
)

```

And finally use the `GeometryCurve.Length` attribute of the ModelCurve to get your elements’ length

```python
OUT = [mc.GeometryCurve.Length for mc in flatten([r.GetProfiles() for r in roofs])]

```

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [November 14, 2023, 11:40pm UTC](https://forum.dynamobim.com/t/how-to-acces-an-curvearrays/95490/5 "2023-11-14T23:40:07Z")

</div>

To keep nesting of multiple roofs use this

```python
modelcurves = [flatten(r.GetProfiles()) for r in roofs]

OUT = [[c.GeometryCurve.Length for c in mc] for mc in modelcurves]

```
