示例#1
0
        public static ZoneReferenceElement ToZoneReferenceElement(this IObject refElement)
        {
            ZoneReferenceElement zoneReferenceElement = refElement as ZoneReferenceElement;

            if (zoneReferenceElement != null)
            {
                return(zoneReferenceElement);
            }

            string    refElZoneName;
            IGeometry referenceGeom;

            if (zoneReferenceElement != null)
            {
                refElZoneName = zoneReferenceElement.ZoneName;
                referenceGeom = zoneReferenceElement.ReferenceGeometry;
            }
            else
            {
                // Allow for CustomObjects with a property named "ZoneName" to be used as reference Elements.
                refElZoneName = refElement.ValueFromSource("ZoneName") as string;
                referenceGeom = BH.Engine.CIH.Query.IGeometry(refElement);
            }

            if (string.IsNullOrWhiteSpace(refElZoneName) || referenceGeom == null)
            {
                return(null);
            }

            return(zoneReferenceElement);
        }
示例#2
0
        public static List <Zone> Zones(List <IObject> referenceElements, ZoneDimensions zoneDimensions)
        {
            List <Zone> zones = new List <Zone>();

            foreach (var refElement in referenceElements)
            {
                ZoneReferenceElement zoneRefEl = refElement.ToZoneReferenceElement();

                if (zoneRefEl.ZoneName != zoneDimensions.ZoneName)
                {
                    continue;
                }

                BoundingBox bb = Query.IElementBoundingBox(zoneRefEl.ReferenceGeometry, zoneDimensions.Width, zoneDimensions.Height, zoneDimensions.Depth);

                if (bb != null)
                {
                    Zone zone = new Zone()
                    {
                        ZoneName = zoneRefEl.ZoneName, ClosedVolume = bb
                    };
                    zones.Add(zone);
                }
            }

            return(zones);
        }