Example #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);
        }
Example #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);
        }
Example #3
0
        /// <summary>
        /// Exports a roof element to the appropriate IFC entity.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="roof">The roof element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void Export(ExporterIFC exporterIFC, RoofBase roof, ref GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                // export parts or not
                bool exportParts         = PartExporter.CanExportParts(roof);
                bool exportAsCurtainRoof = CurtainSystemExporter.IsCurtainSystem(roof);

                // if there is only a single part that we can get from the roof geometry, we will not create the aggregation with IfcSlab, but directly export the IfcRoof
                bool exportAsSingleGeometry = false;
                if (productWrapper != null && !ExporterCacheManager.ExportOptionsCache.ExportAsOlderThanIFC4)
                {
                    exportAsSingleGeometry = IFCAnyHandleUtil.IsNullOrHasNoValue(productWrapper.GetAnElement());
                }

                if (exportParts)
                {
                    if (!PartExporter.CanExportElementInPartExport(roof, roof.LevelId, false))
                    {
                        return;
                    }
                    ExportRoofAsParts(exporterIFC, roof, geometryElement, productWrapper); // Right now, only flat roof could have parts.
                }
                else if (exportAsCurtainRoof)
                {
                    CurtainSystemExporter.ExportCurtainRoof(exporterIFC, roof, productWrapper);
                }
                else
                {
                    string            ifcEnumType;
                    IFCExportInfoPair roofExportType = ExporterUtil.GetProductExportType(exporterIFC, roof, out ifcEnumType);

                    if (roofExportType.ExportInstance != IFCEntityType.IfcRoof)
                    {
                        ExportRoof(exporterIFC, roof, ref geometryElement, productWrapper, exportAsSingleGeometry);
                    }
                    else
                    {
                        IFCAnyHandle roofHnd = ExportRoofOrFloorAsContainer(exporterIFC, roof,
                                                                            geometryElement, productWrapper);
                        if (IFCAnyHandleUtil.IsNullOrHasNoValue(roofHnd))
                        {
                            ExportRoof(exporterIFC, roof, ref geometryElement, productWrapper, exportAsSingleGeometry);
                        }
                    }

                    // call for host objects; curtain roofs excused from call (no material information)
                    if (!ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
                    {
                        HostObjectExporter.ExportHostObjectMaterials(exporterIFC, roof, productWrapper.GetAnElement(),
                                                                     geometryElement, productWrapper, ElementId.InvalidElementId, IFCLayerSetDirection.Axis3, null, null);
                    }
                }
                tr.Commit();
            }
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// Exports a roof element to the appropriate IFC entity.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="roof">The roof element.</param>
        /// <param name="geometryElement">The geometry element.</param>
        /// <param name="productWrapper">The ProductWrapper.</param>
        public static void Export(ExporterIFC exporterIFC, RoofBase roof, GeometryElement geometryElement, ProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            using (IFCTransaction tr = new IFCTransaction(file))
            {
                // export parts or not
                bool exportParts         = PartExporter.CanExportParts(roof);
                bool exportAsCurtainRoof = CurtainSystemExporter.IsCurtainSystem(roof);

                if (exportParts)
                {
                    if (!PartExporter.CanExportElementInPartExport(roof, roof.LevelId, false))
                    {
                        return;
                    }
                    ExportRoofAsParts(exporterIFC, roof, geometryElement, productWrapper); // Right now, only flat roof could have parts.
                }
                else if (exportAsCurtainRoof)
                {
                    CurtainSystemExporter.ExportCurtainRoof(exporterIFC, roof, productWrapper);
                }
                else
                {
                    IFCAnyHandle roofHnd = ExportRoofOrFloorAsContainer(exporterIFC, roof,
                                                                        geometryElement, productWrapper);
                    if (IFCAnyHandleUtil.IsNullOrHasNoValue(roofHnd))
                    {
                        ExportRoof(exporterIFC, roof, geometryElement, productWrapper);
                    }

                    // call for host objects; curtain roofs excused from call (no material information)
                    if (!ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
                    {
                        HostObjectExporter.ExportHostObjectMaterials(exporterIFC, roof, productWrapper.GetAnElement(),
                                                                     geometryElement, productWrapper, ElementId.InvalidElementId, IFCLayerSetDirection.Axis3, null, null);
                    }
                }
                tr.Commit();
            }
        }
Example #6
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);
        }