コード例 #1
0
        /// <summary>
        /// Provides a unified interface to get the curtain grids associated with an element.
        /// </summary>
        /// <param name="element">The host element.</param>
        /// <returns>A CurtainGridSet with 0 or more CurtainGrids, or null if invalid.</returns>
        public static CurtainGridSet GetCurtainGridSet(Element element)
        {
            CurtainGridSet curtainGridSet = null;

            if (element is Wall)
            {
                Wall wall = element as Wall;
                if (!CurtainSystemExporter.IsLegacyCurtainWall(wall))
                {
                    CurtainGrid curtainGrid = wall.CurtainGrid;
                    curtainGridSet = new CurtainGridSet();
                    if (curtainGrid != null)
                    {
                        curtainGridSet.Insert(curtainGrid);
                    }
                }
            }
            else if (element is FootPrintRoof)
            {
                FootPrintRoof footPrintRoof = element as FootPrintRoof;
                curtainGridSet = footPrintRoof.CurtainGrids;
            }
            else if (element is ExtrusionRoof)
            {
                ExtrusionRoof extrusionRoof = element as ExtrusionRoof;
                curtainGridSet = extrusionRoof.CurtainGrids;
            }
            else if (element is CurtainSystem)
            {
                CurtainSystem curtainSystem = element as CurtainSystem;
                curtainGridSet = curtainSystem.CurtainGrids;
            }

            return(curtainGridSet);
        }
コード例 #2
0
        /// <summary>
        /// Exports a curtain wall to IFC curtain wall.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="hostElement">The host object element to be exported.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void ExportWall(ExporterIFC exporterIFC, Wall hostElement, ProductWrapper productWrapper)
        {
            // Don't export the Curtain Wall itself, which has no useful geometry; instead export all of the GReps of the
            // mullions and panels.
            CurtainGridSet gridSet = CurtainSystemExporter.GetCurtainGridSet(hostElement);

            if (gridSet == null)
            {
                ExportLegacyCurtainElement(exporterIFC, hostElement, productWrapper);
                return;
            }

            if (gridSet.Size == 0)
            {
                return;
            }

            HashSet <ElementId> allSubElements = new HashSet <ElementId>();

            foreach (CurtainGrid grid in gridSet)
            {
                allSubElements.UnionWith(GetVisiblePanelsForGrid(grid));
                allSubElements.UnionWith(grid.GetMullionIds());
            }

            ExportBase(exporterIFC, allSubElements, hostElement, productWrapper);
        }
コード例 #3
0
ファイル: CurtainCell.cs プロジェクト: HoareLea/SAM_Revit
        public static CurtainCell CurtainCell(this CurtainSystem curtainSystem, ElementId uGridLineElementId, ElementId vGridLineElementId)
        {
            if (uGridLineElementId == null || uGridLineElementId == ElementId.InvalidElementId || vGridLineElementId == null || vGridLineElementId == ElementId.InvalidElementId)
            {
                return(null);
            }

            CurtainGridSet curtainGridSet = curtainSystem?.CurtainGrids;

            if (curtainGridSet == null)
            {
                return(null);
            }

            foreach (CurtainGrid curtainGrid in curtainGridSet)
            {
                CurtainCell result = curtainGrid.GetCell(uGridLineElementId, vGridLineElementId);
                if (result != null)
                {
                    return(result);
                }
            }

            return(null);
        }
コード例 #4
0
        internal static CurtainGridSet AllCurtainGrids(Autodesk.Revit.DB.Element revitElement)
        {
            CurtainGridSet gridSets = null;

            if (revitElement is CurtainSystem)
            {
                var gridAsCurtainSystem = revitElement as CurtainSystem;
                gridSets = gridAsCurtainSystem.CurtainGrids;
            }
            else if (revitElement is ExtrusionRoof)
            {
                var gridAsExtrusionRoof = revitElement as ExtrusionRoof;
                gridSets = gridAsExtrusionRoof.CurtainGrids;
            }
            else if (revitElement is FootPrintRoof)
            {
                var gridAsFootPrintRoof = revitElement as FootPrintRoof;
                gridSets = gridAsFootPrintRoof.CurtainGrids;
            }
            else if (revitElement is Autodesk.Revit.DB.Wall)
            {
                var gridAsWall = revitElement as Autodesk.Revit.DB.Wall;
                gridSets = new CurtainGridSet();
                gridSets.Insert(gridAsWall.CurtainGrid);
            }

            if (gridSets == null || gridSets.Size < 1)
            {
                throw new Exception("Element has no Curtain Grids");
            }
            return(gridSets);
        }
コード例 #5
0
        /// <summary>
        /// Exports a curtain system to IFC curtain system.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="hostElement">
        /// The curtain system element to be exported.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportCurtainSystem(ExporterIFC exporterIFC, CurtainSystem curtainSystem, IFCProductWrapper productWrapper)
        {
            CurtainGridSet grids = curtainSystem.CurtainGrids;

            if (grids == null || grids.Size == 0)
            {
                return;
            }

            ICollection <ElementId> allSubElements = new HashSet <ElementId>();

            foreach (CurtainGrid grid in grids)
            {
                foreach (ElementId panelId in grid.GetPanelIds())
                {
                    allSubElements.Add(panelId);
                }
                foreach (ElementId subElem in grid.GetMullionIds())
                {
                    allSubElements.Add(subElem);
                }
            }

            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction transaction = new IFCTransaction(file))
            {
                ExportBase(exporterIFC, allSubElements, curtainSystem, productWrapper);
                transaction.Commit();
            }
        }
コード例 #6
0
        /// <summary>
        /// Exports a curtain roof to IFC curtain wall.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="hostElement">
        /// The host object element to be exported.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportFootPrintRoof(ExporterIFC exporterIFC, FootPrintRoof hostElement, IFCProductWrapper productWrapper)
        {
            // Don't export the Curtain Wall itself, which has no useful geometry; instead export all of the GReps of the
            // mullions and panels.
            CurtainGridSet grids = hostElement.CurtainGrids;

            if (grids == null || grids.Size == 0)
            {
                return;
            }

            ICollection <ElementId> allSubElements = new HashSet <ElementId>();

            foreach (CurtainGrid grid in grids)
            {
                foreach (ElementId panelId in grid.GetPanelIds())
                {
                    allSubElements.Add(panelId);
                }
                foreach (ElementId subElem in grid.GetMullionIds())
                {
                    allSubElements.Add(subElem);
                }
            }
            ExportBase(exporterIFC, allSubElements, hostElement, productWrapper);
        }
コード例 #7
0
        /// <summary>
        /// Returns all of the active curtain panels for a CurtainGrid.
        /// </summary>
        /// <param name="curtainGrid">The CurtainGrid element.</param>
        /// <returns>The element ids of the active curtain panels.</returns>
        /// <remarks>CurtainGrid.GetPanelIds() returns the element ids of the curtain panels that are directly contained in the CurtainGrid.
        /// Some of these panels however, are placeholders for "host" panels.  From a user point of view, the host panels are the real panels,
        /// and should replace these internal panels for export purposes.</remarks>
        public static ICollection <ElementId> GetVisiblePanelsForGrid(CurtainGrid curtainGrid)
        {
            ICollection <ElementId> panelIdsIn = curtainGrid.GetPanelIds();

            if (panelIdsIn == null)
            {
                return(null);
            }

            HashSet <ElementId> visiblePanelIds = new HashSet <ElementId>();

            foreach (ElementId panelId in panelIdsIn)
            {
                Element element = ExporterCacheManager.Document.GetElement(panelId);
                if (element == null)
                {
                    continue;
                }

                ElementId hostPanelId = ElementId.InvalidElementId;
                if (element is Panel)
                {
                    hostPanelId = (element as Panel).FindHostPanel();
                }

                if (hostPanelId != ElementId.InvalidElementId)
                {
                    // If the host panel is itself a curtain wall, then we have to recursively collect its element ids.
                    Element hostPanel = ExporterCacheManager.Document.GetElement(hostPanelId);
                    if (IsCurtainSystem(hostPanel))
                    {
                        CurtainGridSet gridSet = CurtainSystemExporter.GetCurtainGridSet(hostPanel);
                        if (gridSet == null || gridSet.Size == 0)
                        {
                            visiblePanelIds.Add(hostPanelId);
                        }
                        else
                        {
                            ICollection <ElementId> allSubElements = GetSubElements(gridSet);
                            visiblePanelIds.UnionWith(allSubElements);
                        }
                    }
                    else
                    {
                        visiblePanelIds.Add(hostPanelId);
                    }
                }
                else
                {
                    visiblePanelIds.Add(panelId);
                }
            }

            return(visiblePanelIds);
        }
コード例 #8
0
        private static ICollection <ElementId> GetSubElements(CurtainGridSet gridSet)
        {
            HashSet <ElementId> allSubElements = new HashSet <ElementId>();

            foreach (CurtainGrid grid in gridSet)
            {
                allSubElements.UnionWith(GetVisiblePanelsForGrid(grid));
                allSubElements.UnionWith(grid.GetMullionIds());
            }

            return(allSubElements);
        }
コード例 #9
0
        /// <summary>
        /// Returns if an element is a legacy or non-legacy curtain system of any base element type.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>True if it is a legacy or non-legacy curtain system of any base element type, false otherwise.</returns>
        public static bool IsCurtainSystem(Element element)
        {
            if (element == null)
            {
                return(false);
            }

            CurtainGridSet curtainGridSet = GetCurtainGridSet(element);

            if (curtainGridSet == null)
            {
                return(element is Wall);
            }
            return(curtainGridSet.Size > 0);
        }
コード例 #10
0
        /// <summary>
        ///get all panels of curtain wall, system or slope glazing roof
        /// </summary>
        /// <param name="hostingElement"></param>
        public static CurtainPanel[] ByElement(Element hostingElement)
        {
            CurtainGridSet thisSet = CurtainGrid.AllCurtainGrids(hostingElement.InternalElement);
            var            result  = new List <CurtainPanel>();

            var enumGrid = thisSet.GetEnumerator();

            for (; enumGrid.MoveNext();)
            {
                var grid   = (Autodesk.Revit.DB.CurtainGrid)enumGrid.Current;
                var ids    = grid.GetPanelIds();
                var idEnum = ids.GetEnumerator();
                for (; idEnum.MoveNext();)
                {
                    var idPanel = idEnum.Current;
                    var panel   = DocumentManager.Instance.CurrentDBDocument.GetElement(idPanel);
                    result.Add(CurtainPanel.FromExisting(panel as Autodesk.Revit.DB.Panel, true));
                }
            }
            return(result.ToArray());
        }
コード例 #11
0
ファイル: Mullion.cs プロジェクト: hipigod/Dynamo
        /// <summary>
        ///get all mullions of curtain wall, system or slope galzing roof
        /// </summary>
        /// <param name="hostingElement"></param>
        public static Mullion[] ByElement(Element hostingElement)
        {
            CurtainGridSet thisSet = CurtainGrid.AllCurtainGrids(hostingElement.InternalElement);
            var            result  = new List <Mullion>();

            var enumGrid = thisSet.GetEnumerator();

            for (; enumGrid.MoveNext();)
            {
                var grid   = (Autodesk.Revit.DB.CurtainGrid)enumGrid.Current;
                var ids    = grid.GetMullionIds();
                var idEnum = ids.GetEnumerator();
                for (; idEnum.MoveNext();)
                {
                    var idMullion = idEnum.Current;
                    var mullion   = DocumentManager.Instance.CurrentDBDocument.GetElement(idMullion);
                    result.Add(Mullion.FromExisting(mullion as Autodesk.Revit.DB.Mullion, true));
                }
            }
            return(result.ToArray());
        }
コード例 #12
0
        public static List <Panel> Panels(this CurtainSystem curtainSystem)
        {
            CurtainGridSet curtainGridSet = curtainSystem?.CurtainGrids;

            if (curtainGridSet == null)
            {
                return(null);
            }

            List <Panel> result = new List <Panel>();

            foreach (CurtainGrid curtainGrid in curtainGridSet)
            {
                List <Panel> panels = Panels(curtainSystem.Document, curtainGrid);
                if (panels != null && panels.Count != 0)
                {
                    result.AddRange(panels);
                }
            }

            return(result);
        }
コード例 #13
0
        /// <summary>
        /// Export non-legacy Curtain Walls and Roofs.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="allSubElements">Collection of elements contained in the host curtain element.</param>
        /// <param name="element">The element to be exported.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        private static void ExportBaseWithGrids(ExporterIFC exporterIFC, Element hostElement, ProductWrapper productWrapper)
        {
            // Don't export the Curtain Wall itself, which has no useful geometry; instead export all of the GReps of the
            // mullions and panels.
            CurtainGridSet gridSet = CurtainSystemExporter.GetCurtainGridSet(hostElement);

            if (gridSet == null)
            {
                if (hostElement is Wall)
                {
                    ExportLegacyCurtainElement(exporterIFC, hostElement as Wall, productWrapper);
                }
                return;
            }

            if (gridSet.Size == 0)
            {
                return;
            }

            ICollection <ElementId> allSubElements = GetSubElements(gridSet);

            ExportBase(exporterIFC, allSubElements, hostElement, productWrapper);
        }
コード例 #14
0
ファイル: CurtainGrid.cs プロジェクト: RobertiF/Dynamo
      internal static CurtainGridSet AllCurtainGrids(Autodesk.Revit.DB.Element revitElement)
      {
         CurtainGridSet gridSets = null;
         if (revitElement is CurtainSystem)
         {
            var gridAsCurtainSystem = revitElement as CurtainSystem;
            gridSets = gridAsCurtainSystem.CurtainGrids;
         }
         else if (revitElement is ExtrusionRoof)
         {
            var gridAsExtrusionRoof = revitElement as ExtrusionRoof;
            gridSets = gridAsExtrusionRoof.CurtainGrids;
         }
         else if (revitElement is FootPrintRoof)
         {
            var gridAsFootPrintRoof = revitElement as FootPrintRoof;
            gridSets = gridAsFootPrintRoof.CurtainGrids;
         }
         else if (revitElement is Autodesk.Revit.DB.Wall)
         {
            var gridAsWall = revitElement as Autodesk.Revit.DB.Wall;
            gridSets = new CurtainGridSet();
            gridSets.Insert(gridAsWall.CurtainGrid);
         }

         if (gridSets == null || gridSets.Size < 1)
         {
            throw new Exception("Element has no Curtain Grids");
         }
         return gridSets;
      }
コード例 #15
0
        /// <summary>
        /// Provides a unified interface to get the curtain grids associated with an element.
        /// </summary>
        /// <param name="element">The host element.</param>
        /// <returns>A CurtainGridSet with 0 or more CurtainGrids, or null if invalid.</returns>
        public static CurtainGridSet GetCurtainGridSet(Element element)
        {
            CurtainGridSet curtainGridSet = null;
            if (element is Wall)
            {
                Wall wall = element as Wall;
                if (!CurtainSystemExporter.IsLegacyCurtainWall(wall))
                {
                    CurtainGrid curtainGrid = wall.CurtainGrid;
                    curtainGridSet = new CurtainGridSet();
                    if (curtainGrid != null)
                        curtainGridSet.Insert(curtainGrid);
                }
            }
            else if (element is FootPrintRoof)
            {
                FootPrintRoof footPrintRoof = element as FootPrintRoof;
                curtainGridSet = footPrintRoof.CurtainGrids;
            }
            else if (element is ExtrusionRoof)
            {
                ExtrusionRoof extrusionRoof = element as ExtrusionRoof;
                curtainGridSet = extrusionRoof.CurtainGrids;
            }
            else if (element is CurtainSystem)
            {
                CurtainSystem curtainSystem = element as CurtainSystem;
                curtainGridSet = curtainSystem.CurtainGrids;
            }

            return curtainGridSet;
        }
コード例 #16
0
        private static List <Face3D> Profiles_CurtainSystem(this CurtainSystem curtainSystem)
        {
            Document document = curtainSystem?.Document;

            if (document == null)
            {
                return(null);
            }

            CurtainGridSet curtainGridSet = curtainSystem?.CurtainGrids;

            if (curtainGridSet == null)
            {
                return(null);
            }

            List <Face3D> result = new List <Face3D>();

            foreach (CurtainGrid curtainGrid in curtainGridSet)
            {
                IEnumerable <CurtainCell> curtainCells = curtainGrid.GetCurtainCells();
                if (curtainCells == null || curtainCells.Count() == 0)
                {
                    continue;
                }

                List <CurveArrArray> curveArrArrays = new List <CurveArrArray>();
                foreach (CurtainCell curtainCell in curtainCells)
                {
                    CurveArrArray curveArrArray = curtainCell?.PlanarizedCurveLoops;
                    if (curveArrArray == null || curveArrArray.Size == 0)
                    {
                        continue;
                    }

                    curveArrArrays.Add(curveArrArray);
                }

                List <Segment3D>      segment3Ds       = new List <Segment3D>();
                List <ISegmentable3D> segmentable3Ds_U = new List <ISegmentable3D>();
                List <ISegmentable3D> segmentable3Ds_V = new List <ISegmentable3D>();

                ICollection <ElementId> elementIds = null;

                elementIds = curtainGrid.GetUGridLineIds();
                if (elementIds != null)
                {
                    foreach (ElementId elementId in elementIds)
                    {
                        CurtainGridLine curtainGridLine = document.GetElement(elementId) as CurtainGridLine;
                        if (curtainGridLine == null)
                        {
                            continue;
                        }

                        ISegmentable3D segmentable3D = curtainGridLine.FullCurve.ToSAM() as ISegmentable3D;
                        if (segmentable3D == null)
                        {
                            continue;
                        }

                        segmentable3Ds_U.Add(segmentable3D);
                        segment3Ds.AddRange(segmentable3D.GetSegments());
                    }
                }

                elementIds = curtainGrid.GetVGridLineIds();
                if (elementIds != null)
                {
                    foreach (ElementId elementId in elementIds)
                    {
                        CurtainGridLine curtainGridLine = document.GetElement(elementId) as CurtainGridLine;
                        if (curtainGridLine == null)
                        {
                            continue;
                        }

                        ISegmentable3D segmentable3D = curtainGridLine.FullCurve.ToSAM() as ISegmentable3D;
                        if (segmentable3D == null)
                        {
                            continue;
                        }

                        segmentable3Ds_V.Add(segmentable3D);
                        segment3Ds.AddRange(segmentable3D.GetSegments());
                    }
                }

                List <ISegmentable3D> segmentable3Ds = null;

                segmentable3Ds = ExtremeSegmentable3Ds(segmentable3Ds_U, segmentable3Ds_V);
                if (segmentable3Ds != null && segmentable3Ds.Count > 0)
                {
                    foreach (ISegmentable3D segmentable3D in segmentable3Ds)
                    {
                        List <Segment3D> segment3Ds_Temp = segmentable3D?.GetSegments();
                        if (segment3Ds_Temp != null && segment3Ds_Temp.Count != 0)
                        {
                            segment3Ds.AddRange(segment3Ds_Temp);
                        }
                    }
                }

                segmentable3Ds = ExtremeSegmentable3Ds(segmentable3Ds_V, segmentable3Ds_U);
                if (segmentable3Ds != null && segmentable3Ds.Count > 0)
                {
                    foreach (ISegmentable3D segmentable3D in segmentable3Ds)
                    {
                        List <Segment3D> segment3Ds_Temp = segmentable3D?.GetSegments();
                        if (segment3Ds_Temp != null && segment3Ds_Temp.Count != 0)
                        {
                            segment3Ds.AddRange(segment3Ds_Temp);
                        }
                    }
                }


                List <List <Face3D> > face3Ds = Enumerable.Repeat <List <Face3D> >(null, curveArrArrays.Count).ToList();
                Parallel.For(0, curveArrArrays.Count, (int i) =>
                {
                    CurveArrArray curveArrArray = curveArrArrays[i];
                    if (curveArrArray == null || curveArrArray.Size == 0)
                    {
                        return;
                    }

                    face3Ds[i] = new List <Face3D>();
                    foreach (CurveArray curveArray in curveArrArray)
                    {
                        Polygon3D polygon3D = curveArray?.ToSAM_Polygon3D();
                        if (polygon3D == null && !polygon3D.IsValid())
                        {
                            continue;
                        }

                        Spatial.Plane plane = polygon3D.GetPlane();
                        if (plane == null)
                        {
                            continue;
                        }

                        Polygon2D polygon2D = plane.Convert(polygon3D);
                        if (polygon2D != null)
                        {
                            List <Segment2D> segment2Ds = segment3Ds.ConvertAll(x => plane.Convert(plane.Project(x)));
                            segment2Ds.RemoveAll(x => x == null || x.GetLength() < Core.Tolerance.MacroDistance);
                            segment2Ds = segment2Ds.Split();

                            List <Polygon2D> polygon2Ds = Planar.Create.Polygon2Ds(segment2Ds);
                            if (polygon2Ds != null)
                            {
                                polygon2Ds = polygon2Ds.FindAll(x => x.Inside(polygon2D));
                                if (polygon2Ds != null && polygon2Ds.Count > 0)
                                {
                                    polygon2Ds.Sort((x, y) => y.GetArea().CompareTo(x.GetArea()));
                                    polygon3D = plane.Convert(polygon2Ds[0]);
                                }
                            }
                        }

                        face3Ds[i].Add(new Face3D(polygon3D));
                    }
                });

                foreach (List <Face3D> face3Ds_Temp in face3Ds)
                {
                    if (face3Ds_Temp != null && face3Ds_Temp.Count > 0)
                    {
                        result.AddRange(face3Ds_Temp);
                    }
                }
            }

            return(result);
        }