Thank you, it realy help me. But i have some question. As example. If in wall i make Rectangular Straight Wall Opening (RSWO in future ), and use code to this wall, i see ElementId of RSWO, and other connecting walls. But if i select RSWO and use code to it, i dont see wall Element Id in which RSWO mount. Why this happening?
By the way, i write on pyRevit, and dont use some types as you in CS.
My script now:
__doc__ = "Find all Element that connected to select wall"
__title__ = 'All\nElementIds'
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
from Autodesk.Revit.DB.Analysis import *
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
def get_selected_elements(doc):
"""API change in Revit 2016 makes old method throw an error"""
try:
# Revit 2016
return [doc.GetElement(id)
for id in __revit__.ActiveUIDocument.Selection.GetElementIds()]
except:
# old method
return list(__revit__.ActiveUIDocument.Selection.Elements)
selection = get_selected_elements(doc)
for el in selection:
print el.Id
if len(selection):
s0 = selection[0]
list = []
option = Options()
geometryElement = s0.get_Geometry(option)
for geometryObject in geometryElement:
for face in geometryObject.Faces:
geometryElementIds = s0.GetGeneratingElementIds(face)
geometryElementIds.Remove(s0.Id)
for ElementId in geometryElementIds:
if list.Contains(ElementId) == False:
list.Add(ElementId)
print list