Ejemplo n.º 1
0
        /// <summary>
        /// Checks if element in certain category should be exported.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="allowSeparateOpeningExport">True if IfcOpeningElement is allowed to be exported.</param>
        /// <returns>True if the element should be exported, false otherwise.</returns>
        private static bool ShouldCategoryBeExported(ExporterIFC exporterIFC, Element element, bool allowSeparateOpeningExport)
        {
            IFCExportInfoPair exportType = new IFCExportInfoPair();
            ElementId         categoryId;
            string            ifcClassName = ExporterUtil.GetIFCClassNameFromExportTable(exporterIFC, element, out categoryId);

            if (string.IsNullOrEmpty(ifcClassName))
            {
                // Special case: these elements aren't contained in the default export layers mapping table.
                // This allows these elements to be exported by default.
                if (element is AreaScheme || element is Group)
                {
                    ifcClassName = "IfcGroup";
                }
                else if (element is ElectricalSystem)
                {
                    ifcClassName = "IfcSystem";
                }
                else
                {
                    return(false);
                }
            }

            bool foundName = string.Compare(ifcClassName, "Default", true) != 0;

            if (foundName)
            {
                exportType = GetExportTypeFromClassName(ifcClassName);
            }
            if (!foundName)
            {
                return(true);
            }

            if (exportType.ExportInstance == IFCEntityType.UnKnown)
            {
                return(false);
            }

            // We don't export openings directly, only via the element they are opening, unless flag is set.
            if (exportType.ExportInstance == IFCEntityType.IfcOpeningElement && !allowSeparateOpeningExport)
            {
                return(false);
            }

            // Check whether the intended Entity type is inside the export exclusion set
            IFCEntityType elementClassTypeEnum;

            if (Enum.TryParse(exportType.ExportInstance.ToString(), out elementClassTypeEnum) ||
                Enum.TryParse(exportType.ExportType.ToString(), out elementClassTypeEnum))
            {
                if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a list of geometry objects to export from an initial list of solids and meshes, excluding invisible and not exported categories.
        /// </summary>
        /// <param name="doc">The document.</param>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="solids">The list of solids, possibly empty.</param>
        /// <param name="meshes">The list of meshes, possibly empty.</param>
        /// <returns>The combined list of solids and meshes that are visible given category export settings and view visibility settings.</returns>
        public static List <GeometryObject> RemoveInvisibleSolidsAndMeshes(Document doc, ExporterIFC exporterIFC, IList <Solid> solids, IList <Mesh> meshes)
        {
            List <GeometryObject> geomObjectsIn = new List <GeometryObject>();

            if (solids != null && solids.Count > 0)
            {
                geomObjectsIn.AddRange(solids);
            }
            if (meshes != null && meshes.Count > 0)
            {
                geomObjectsIn.AddRange(meshes);
            }

            List <GeometryObject> geomObjectsOut = new List <GeometryObject>();

            View filterView = ExporterCacheManager.ExportOptionsCache.FilterViewForExport;

            foreach (GeometryObject obj in geomObjectsIn)
            {
                GraphicsStyle gStyle = doc.GetElement(obj.GraphicsStyleId) as GraphicsStyle;
                if (gStyle != null)
                {
                    Category graphicsStyleCategory = gStyle.GraphicsStyleCategory;
                    if (graphicsStyleCategory != null)
                    {
                        if (!ElementFilteringUtil.IsCategoryVisible(graphicsStyleCategory, filterView))
                        {
                            continue;
                        }

                        ElementId catId = graphicsStyleCategory.Id;

                        string ifcClassName = ExporterUtil.GetIFCClassNameFromExportTable(exporterIFC, catId);
                        if (!string.IsNullOrEmpty(ifcClassName))
                        {
                            bool foundName = String.Compare(ifcClassName, "Default", true) != 0;
                            if (foundName)
                            {
                                IFCExportInfoPair exportType = ElementFilteringUtil.GetExportTypeFromClassName(ifcClassName);
                                if (exportType.ExportInstance == IFCEntityType.UnKnown)
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }
                geomObjectsOut.Add(obj);
            }

            return(geomObjectsOut);
        }