Esempio n. 1
0
        /// <summary>
        ///     Gets the room's edge list.
        /// </summary>
        /// <param name="room"></param>
        /// <param name="boundary"></param>
        /// <returns></returns>
        public static List <Line> GetEdgeList(this SpatialElement room, SpatialElementBoundaryLocation boundary)
        {
            if (room == null)
            {
                throw new ArgumentNullException(nameof(room));
            }

            var result = new List <Line>();
            var opt    = new SpatialElementBoundaryOptions
            {
                StoreFreeBoundaryFaces         = true,
                SpatialElementBoundaryLocation = boundary
            };
            var segments = room.GetBoundarySegments(opt).SelectMany(s => s);

            foreach (var seg in segments)
            {
                var sp = seg.GetCurve().GetEndPoint(0);
                var ep = seg.GetCurve().GetEndPoint(1);

                result.Add(Line.CreateBound(sp, ep));
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        ///     Returns intersection element list.
        /// </summary>
        /// <param name="room"></param>
        /// <param name="doc"></param>
        /// <param name="loc"></param>
        /// <returns></returns>
        public static List <Element> IntersectElementList(this SpatialElement room, Document doc, SpatialElementBoundaryLocation loc = default)
        {
            if (room is null)
            {
                throw new ArgumentNullException(nameof(room));
            }

            if (doc is null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            var opt = new SpatialElementBoundaryOptions {
                SpatialElementBoundaryLocation = loc
            };
            var calc       = new SpatialElementGeometryCalculator(doc, opt);
            var solid      = calc.CalculateSpatialElementGeometry(room).GetGeometry();
            var instFilter = new FilteredElementCollector(doc).WhereElementIsNotElementType();
            var itstFilter = new ElementIntersectsSolidFilter(solid);

            return(instFilter.WherePasses(itstFilter).ToList());
        }