Get the element of the selected edge

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

screenshot1

maybe someone can point me in the right direction, thanks

OOTB, I am not sure how to do that. But using springnodes, we can add an additional output to his node.
image

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
5 Likes

Thanks, worked perfectly

1 Like

@john_pierson Perfect.

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

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

to
edge.ToDSType()

Yea i thought about it but a iget an error.

erreor

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.

Thnaks . i open new topic

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?