/// <summary>
        /// Exports curtain object as container.
        /// </summary>
        /// <param name="allSubElements">
        /// Collection of elements contained in the host curtain element.
        /// </param>
        /// <param name="wallElement">
        /// The curtain wall element.
        /// </param>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        public static void ExportCurtainObjectCommonAsContainer(ICollection <ElementId> allSubElements, Element wallElement,
                                                                ExporterIFC exporterIFC, ProductWrapper origWrapper, IFCPlacementSetter currSetter)
        {
            if (wallElement == null)
            {
                return;
            }

            string overrideCADLayer = null;

            ParameterUtil.GetStringValueFromElementOrSymbol(wallElement, "IFCCadLayer", out overrideCADLayer);

            using (ExporterStateManager.CADLayerOverrideSetter layerSetter = new ExporterStateManager.CADLayerOverrideSetter(overrideCADLayer))
            {
                HashSet <ElementId> alreadyVisited = new HashSet <ElementId>();  // just in case.
                Options             geomOptions    = GeometryUtil.GetIFCExportGeometryOptions();
                {
                    foreach (ElementId subElemId in allSubElements)
                    {
                        using (ProductWrapper productWrapper = ProductWrapper.Create(origWrapper))
                        {
                            Element subElem = wallElement.Document.GetElement(subElemId);
                            if (subElem == null)
                            {
                                continue;
                            }

                            if (alreadyVisited.Contains(subElem.Id))
                            {
                                continue;
                            }
                            alreadyVisited.Add(subElem.Id);

                            // Respect element visibility settings.
                            if (!ElementFilteringUtil.CanExportElement(exporterIFC, subElem, false) || !ElementFilteringUtil.IsElementVisible(subElem))
                            {
                                continue;
                            }

                            GeometryElement geomElem = subElem.get_Geometry(geomOptions);
                            if (geomElem == null)
                            {
                                continue;
                            }

                            try
                            {
                                if (subElem is FamilyInstance)
                                {
                                    if (subElem is Mullion)
                                    {
                                        if (exporterIFC.ExportAs2x2)
                                        {
                                            ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper);
                                        }
                                        else
                                        {
                                            IFCAnyHandle currLocalPlacement = currSetter.GetPlacement();
                                            MullionExporter.Export(exporterIFC, subElem as Mullion, geomElem, currLocalPlacement, currSetter,
                                                                   productWrapper);
                                        }
                                    }
                                    else
                                    {
                                        FamilyInstance subFamInst = subElem as FamilyInstance;

                                        string        ifcEnumType;
                                        IFCExportType exportType = ExporterUtil.GetExportType(exporterIFC, subElem, out ifcEnumType);
                                        if (exportType == IFCExportType.ExportCurtainWall)
                                        {
                                            // By default, panels and mullions are set to the same category as their parent.  In this case,
                                            // ask to get the exportType from the category id, since we don't want to inherit the parent class.
                                            ElementId catId = CategoryUtil.GetSafeCategoryId(subElem);
                                            exportType = ElementFilteringUtil.GetExportTypeFromCategoryId(catId, out ifcEnumType);
                                        }


                                        if (ExporterCacheManager.ExportOptionsCache.ExportAs2x2)
                                        {
                                            if ((exportType == IFCExportType.DontExport) || (exportType == IFCExportType.ExportPlateType) ||
                                                (exportType == IFCExportType.ExportMemberType))
                                            {
                                                exportType = IFCExportType.ExportBuildingElementProxyType;
                                            }
                                        }
                                        else
                                        {
                                            if (exportType == IFCExportType.DontExport)
                                            {
                                                ifcEnumType = "CURTAIN_PANEL";
                                                exportType  = IFCExportType.ExportPlateType;
                                            }
                                        }

                                        IFCAnyHandle currLocalPlacement = currSetter.GetPlacement();
                                        using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
                                        {
                                            FamilyInstanceExporter.ExportFamilyInstanceAsMappedItem(exporterIFC, subFamInst, exportType, ifcEnumType, productWrapper,
                                                                                                    ElementId.InvalidElementId, null, currLocalPlacement);
                                        }
                                    }
                                }
                                else if (subElem is CurtainGridLine)
                                {
                                    ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper);
                                }
                                else if (subElem is Wall)
                                {
                                    WallExporter.ExportWall(exporterIFC, subElem, geomElem, productWrapper);
                                }
                            }
                            catch (Exception ex)
                            {
                                if (ExporterUtil.IsFatalException(wallElement.Document, ex))
                                {
                                    throw ex;
                                }
                                continue;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Exports curtain object as container.
        /// </summary>
        /// <param name="allSubElements">
        /// Collection of elements contained in the host curtain element.
        /// </param>
        /// <param name="wallElement">
        /// The curtain wall element.
        /// </param>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportCurtainObjectCommonAsContainer(ICollection <ElementId> allSubElements, Element wallElement,
                                                                ExporterIFC exporterIFC, IFCProductWrapper origWrapper)
        {
            if (wallElement == null)
            {
                return;
            }

            HashSet <ElementId> alreadyVisited = new HashSet <ElementId>();  // just in case.
            Options             geomOptions    = GeometryUtil.GetIFCExportGeometryOptions();
            {
                foreach (ElementId subElemId in allSubElements)
                {
                    using (IFCProductWrapper productWrapper = IFCProductWrapper.Create(origWrapper))
                    {
                        Element subElem = wallElement.Document.GetElement(subElemId);
                        if (subElem == null)
                        {
                            continue;
                        }
                        GeometryElement geomElem = subElem.get_Geometry(geomOptions);
                        if (geomElem == null)
                        {
                            continue;
                        }

                        if (alreadyVisited.Contains(subElem.Id))
                        {
                            continue;
                        }
                        alreadyVisited.Add(subElem.Id);

                        try
                        {
                            if (subElem is FamilyInstance)
                            {
                                if (subElem is Mullion)
                                {
                                    if (exporterIFC.ExportAs2x2)
                                    {
                                        ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper);
                                    }
                                    else
                                    {
                                        using (IFCPlacementSetter currSetter = IFCPlacementSetter.Create(exporterIFC, wallElement))
                                        {
                                            IFCAnyHandle currLocalPlacement = currSetter.GetPlacement();
                                            using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
                                            {
                                                MullionExporter.Export(exporterIFC, subElem as Mullion, geomElem, currLocalPlacement, extraParams, currSetter,
                                                                       productWrapper);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    FamilyInstance subFamInst = subElem as FamilyInstance;

                                    string        ifcEnumType;
                                    ElementId     catId      = CategoryUtil.GetSafeCategoryId(subElem);
                                    IFCExportType exportType = ElementFilteringUtil.GetExportTypeFromCategoryId(catId, out ifcEnumType);

                                    if (exporterIFC.ExportAs2x2)
                                    {
                                        if ((exportType == IFCExportType.DontExport) || (exportType == IFCExportType.ExportPlateType) ||
                                            (exportType == IFCExportType.ExportMemberType))
                                        {
                                            exportType = IFCExportType.ExportBuildingElementProxy;
                                        }
                                    }
                                    else
                                    {
                                        if (exportType == IFCExportType.DontExport)
                                        {
                                            ifcEnumType = "CURTAIN_PANEL";
                                            exportType  = IFCExportType.ExportPlateType;
                                        }
                                    }
                                    FamilyInstanceExporter.ExportFamilyInstanceAsMappedItem(exporterIFC, subFamInst, exportType, ifcEnumType, productWrapper,
                                                                                            ElementId.InvalidElementId, null);
                                }
                            }
                            else if (subElem is CurtainGridLine)
                            {
                                ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper);
                            }
                        }
                        catch (Exception ex)
                        {
                            if (ExporterUtil.IsFatalException(wallElement.Document, ex))
                            {
                                throw ex;
                            }
                            continue;
                        }
                    }
                }
            }
        }