public static List <ElementId> collectwindows(Document doc, Room room, List <ElementId> listfenid) { SpatialElementBoundaryOptions options = new SpatialElementBoundaryOptions(); SpatialElement piece = room as SpatialElement; BoundingBoxXYZ bbpiece = piece.get_BoundingBox(null); IList <IList <BoundarySegment> > contourpiece = piece.GetBoundarySegments(options); Outline outroom = new Outline(new XYZ(bbpiece.Min.X, bbpiece.Min.Y, bbpiece.Min.Z), new XYZ(bbpiece.Max.X, bbpiece.Max.Y, bbpiece.Max.Z)); BoundingBoxIntersectsFilter bbfilter = new BoundingBoxIntersectsFilter(outroom); FilteredElementCollector windows = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows).WherePasses(bbfilter).WhereElementIsNotElementType(); List <ElementId> fenetres = windows.ToElementIds().ToList(); foreach (ElementId fenid in listfenid) { if (fenetres.Contains(fenid)) { fenetres.Remove(fenid); } } return(fenetres); }
protected override void SolveInstance(IGH_DataAccess dataAccess) { bool run = false; if (!dataAccess.GetData(3, ref run) || !run) { return; } SpatialElement spatialElement = null; if (!dataAccess.GetData(0, ref spatialElement) || spatialElement == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } Document document = spatialElement.Document; Level level_Low = null; dataAccess.GetData(1, ref level_Low); Level level_High = null; dataAccess.GetData(2, ref level_High); if (level_Low == null || level_High == null) { BoundingBoxXYZ boundingBoxXYZ = spatialElement.get_BoundingBox(null); if (boundingBoxXYZ != null) { if (level_Low == null) { level_Low = Core.Revit.Query.LowLevel(document, boundingBoxXYZ.Min.Z); } if (level_High == null) { level_High = Core.Revit.Query.HighLevel(document, boundingBoxXYZ.Max.Z); } } } if (level_Low == null || level_High == null) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } #if Revit2017 || Revit2018 || Revit2019 || Revit2020 double elevation_Low = Units.Revit.Convert.ToSI(level_Low.Elevation, UnitType.UT_Length); double elevation_High = Units.Revit.Convert.ToSI(level_High.Elevation, UnitType.UT_Length); #else double elevation_Low = Units.Revit.Convert.ToSI(level_Low.Elevation, SpecTypeId.Length); double elevation_High = Units.Revit.Convert.ToSI(level_High.Elevation, SpecTypeId.Length); #endif ConvertSettings convertSettings = new ConvertSettings(true, true, true); List <Panel> result = Analytical.Revit.Create.Panels(spatialElement, elevation_Low, elevation_High, convertSettings); dataAccess.SetDataList(0, result.ConvertAll(x => new GooPanel(x))); }