# Get the element of the selected edge

**URL:** <https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489>\
**Category:** Revit\
**Created:** [July 6, 2018, 9:21pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489 "2018-07-06T21:21:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerstal82](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gerstal82](https://forum.dynamobim.com/u/gerstal82)\
**Post date:** [July 6, 2018, 9:21pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/1 "2018-07-06T21:21:26Z")

</div>

It’s probably stupidly simple but i cant figure out how to get the the displayed element id of the selected egde

![screenshot1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/d/bda7c6ae0aa7560a5fbbea1184c8b2db4bfc3ed9.PNG)

maybe someone can point me in the right direction, thanks

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [July 6, 2018, 10:04pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/2 "2018-07-06T22:04:03Z")

</div>

OOTB, I am not sure how to do that. But using `springnodes`, we can add an additional output to his node.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/6/b69f47a870dc12984c8d5c3a93b11560e1d2a3c1.png)

# Paste the following python script into a fresh Python node.

```
#Copyright(c) 2016, Dimitar Venkov
# @5devene, dimitar.ven@gmail.com

import clr

clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

sel1 = uidoc.Selection
ot1 = Selection.ObjectType.Edge
refs = sel1.PickObjects(ot1, "Select the desired edges and press Finish")
edges = []
for i in xrange(len(refs)):
	el1 = doc.GetElement(refs[i].ElementId)
	edge = el1.GetGeometryObjectFromReference(refs[i])
	edges.append(edge.AsCurve().ToProtoType())
OUT = edges,el1
```

---

<div class="post-metadata">

**Author:** ![gerstal82](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gerstal82](https://forum.dynamobim.com/u/gerstal82)\
**Post date:** [July 7, 2018, 7:33am UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/3 "2018-07-07T07:33:14Z")

</div>

Thanks, worked perfectly

---

<div class="post-metadata">

**Author:** ![amir.aroesti](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amir.aroesti/32/130247_2.png) [@amir.aroesti](https://forum.dynamobim.com/u/amir.aroesti)\
**Post date:** [June 17, 2021, 9:47am UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/4 "2021-06-17T09:47:23Z")

</div>

@john_pierson Perfect.

How can I return the edge as Edge and no as Curve?

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 17, 2021, 12:33pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/5 "2021-06-17T12:33:29Z")

</div>

Change this from  
`edge.AsCurve().ToProtoType()`

to  
`edge.ToDSType()`

---

<div class="post-metadata">

**Author:** ![amir.aroesti](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amir.aroesti/32/130247_2.png) [@amir.aroesti](https://forum.dynamobim.com/u/amir.aroesti)\
**Post date:** [June 17, 2021, 12:46pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/6 "2021-06-17T12:46:00Z")

</div>

Yea i thought about it but a iget an error.

![erreor](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/7/97eef1ba47630f4ec7c94fd5e228b82d81f6653f.png)

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [June 17, 2021, 1:08pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/7 "2021-06-17T13:08:42Z")

</div>

k, do this instead.

Change this from  
`edge.AsCurve().ToProtoType()`

to  
`edge`

beyond that, open a new topic and try to explain what you are wanting to do with edges.

---

<div class="post-metadata">

**Author:** ![amir.aroesti](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amir.aroesti/32/130247_2.png) [@amir.aroesti](https://forum.dynamobim.com/u/amir.aroesti)\
**Post date:** [June 17, 2021, 2:18pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/8 "2021-06-17T14:18:16Z")

</div>

Thnaks . i open new topic

---

<div class="post-metadata">

**Author:** ![yjouzou](https://avatars.discourse-cdn.com/v4/letter/y/da6949/32.png) [@yjouzou](https://forum.dynamobim.com/u/yjouzou)\
**Post date:** [August 9, 2022, 12:41pm UTC](https://forum.dynamobim.com/t/get-the-element-of-the-selected-edge/23489/9 "2022-08-09T12:41:58Z")

</div>

Hello guys, while I was searching how to solve this problem I found this solution. It’s exactly what I’m searching for except that with multi-edges from different families it gives me only one family in the output.  
So how can we get the family of every edge selected?

 ![Screenshot-1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/0/705563f6c2404deec318efcdb74521962d170707.png)
