Hello everyone,
how can we get the family or element of every selected edge?
Thanks in advance
Hi,
Yes unfortunately for you, although the node knows which element it is coming from, it’s only returning the Edge as a Curve.
However we can return that ourselves if we use a bit of Python to run the PickObjects command…
import clr
#this gives the object type enumeration
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
element_Id_List = uidoc.Selection.PickObjects(ObjectType.Edge)
OUT = [doc.GetElement(element_Id) for element_Id in element_Id_List]
Remember to click ‘Finish’ to complete the command
Hope that helps,
Mark
Thank you Mark that’s cool but now I only get the families.
Is it possible to get 2 lists. For example the list for edges I selected and the list of families?
yes I mean the curves from edges and families
you have edges as input, families as output, just create a list and attach both the lists just in case if you dont want the python script to do these in one go.
Hi Gideonkarthik,
I actually did that but the output of the curves is (Autodesk.Revit.DB.Reference) while I want them as curves. For example (lines, Nurbscurve, etc)
Hi,
Try this
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript import Geometry as geom
#this gives the object type enumeration
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
element_Reference_List = uidoc.Selection.PickObjects(ObjectType.Edge)
element_List = [doc.GetElement(element_Reference) for element_Reference in element_Reference_List]
line_List = []
for ref, elem in zip(element_Reference_List, element_List):
line_List.append(elem.GetGeometryObjectFromReference(ref).AsCurve().ToProtoType())
OUT = element_List, line_List
Hope that helps,
Mark
That’s awesome, thank you Mark
Hello Mark,
Do you know maybe if is it possible to pick edges only of one category elements?
for example in active view we want to select only edges of Floors elements?
Thanks you in advance!
Heya,
Just to save these posts getting extra long and having several solutions, it’s best to create a new one and reference this one
But yes, this solution just uses:
uidoc.Selection.PickObjects(ObjectType.Edge)
We could use
uidoc.Selection.PickObjects(ObjectType.Edge, ISelectionFilter)
There is an example of making a custom selection filter here:
Hope that helps,
Mark
Mark,
I pick 3 different edges, 1 edge per element and your script returns the element ID, however, it returns the 3 edges sharing the same values, even though the edges selected are differing vectors.
Any thoughts on how this can be resolved?