# DesignScript If-statement not working when trying to convert ModelCurves/Grids into Dynamo Lines

**URL:** <https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962>\
**Category:** DesignScript\
**Tags:** revit\
**Created:** [April 11, 2024, 8:27pm UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962 "2024-04-11T20:27:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [April 11, 2024, 8:27pm UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962/1 "2024-04-11T20:27:17Z")

</div>

Hi all,

I have a script and I would like it to work with both ModelCurves or Grids as input selection by the end user seamlessly. I have gotten it to work, using the nodes on the right, so it’s not a big deal if I can’t get the DesignScript to work but I would like to understand why my DesignScript doesn’t work here.

PS: The function.apply nodes on the right are just to suppress unwanted errors when trying to convert lines using the Grid.Curve node.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/6/3646e0081fe431bde1675d533c8d8b4c4a14f84b.png)

```auto
DSCore.Object.Type(elements) == "Revit.Elements.Grid" ?
	Grid.Curve(elements) :
		Revit.Element.Geometry(elements);

```

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [April 11, 2024, 9:04pm UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962/2 "2024-04-11T21:04:45Z")

</div>

You’re asking if a DSCore.List object is a Grid. The answer is ‘no more than my grocery list is dinner’ so this looks right to me.

Try asking @L1 or with longest lacing or specify the data structure. 🙂

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [April 12, 2024, 8:15am UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962/3 "2024-04-12T08:15:53Z")

</div>

I’m not too familiar with apply list levels and list lacing directly in DesignScript, how would I do that? I’m going to check it in the documentation now but thought to let you know in the meantime.

---

<div class="post-metadata">

**Author:** ![Huettig](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@Huettig](https://forum.dynamobim.com/u/Huettig)\
**Post date:** [April 12, 2024, 10:01am UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962/4 "2024-04-12T10:01:02Z")

</div>

Hey, list levels in design script are pretty straight forward  
“@L2”

 ![test](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/1/5111b85f6126f5caa032a0c34af12abf705856f0.png)

use block to code on some test notes to get a hang of things:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/e/4e0ef17ff50228621d7180b3818d6e07bfcdd286.png)

list lacing is atleast for me a little more complex:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c48c453643269d3f5435832acf0ef500fbb2297e.png)  
Source is on Page 28:  
[DesignScriptGuide\_.pdf](https://forum.dynamobim.com/uploads/short-url/zr7Trn1vS3ZFdXPtK2btPMXNfHk.pdf) (460.1 KB)

Glood luck

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [April 12, 2024, 3:18pm UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962/5 "2024-04-12T15:18:13Z")

</div>

Thanks for the suggestion @Huettig , however I just can’t get the Grid.Curve to give me anything, no matter what level or lacing option. The Element.Geometry ‘option’ works fine though

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 12, 2024, 8:59pm UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962/6 "2024-04-12T20:59:30Z")

</div>

The problem is that `Element.Geometry` returns a list. Just use an If statement with `CurveElement.Curve` instead of `Element.Geometry`.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/7/57f78e234b07ff9a7bcbec540ac52f631ce22ad5.png)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [April 13, 2024, 1:40pm UTC](https://forum.dynamobim.com/t/designscript-if-statement-not-working-when-trying-to-convert-modelcurves-grids-into-dynamo-lines/99962/7 "2024-04-13T13:40:39Z")

</div>

Thanks @Nick_Boyts !! I already suspected something regarding that but wasn’t able to get it to work. I knew there was a node specifically for getting the geometry from Revit curves but couldn’t find it so I tried Element.Geometry instead.
