Example #1
0
        // Cannot be implemented until ExportLayerTable can be read.  Replacement is ShouldCategoryBeExported()

        /*private static ElementFilter GetCategoryFilter()
         * {
         *
         * }*/

        /// <summary>
        /// Checks if element in certain category should be exported.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <returns>True if the element should be exported, false otherwise.</returns>
        public static bool ShouldCategoryBeExported(ExporterIFC exporterIFC, Element element)
        {
            IFCExportType exportType   = IFCExportType.DontExport;
            String        ifcClassName = ExporterIFCUtils.GetIFCClassName(element, exporterIFC);

            if (ifcClassName == "")
            {
                return(false);
            }

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

            if (foundName)
            {
                exportType = GetExportTypeFromClassName(ifcClassName);
            }
            // We don't export openings directly, only via the element they are opening.
            if (!foundName || (exportType != IFCExportType.DontExport && exportType != IFCExportType.ExportOpeningElement))
            {
                return(true);
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Gets export type for an element.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="enumTypeValue">
        /// The output string value represents the enum type.
        /// </param>
        /// <returns>
        /// The IFCExportType.
        /// </returns>
        public static IFCExportType GetExportType(ExporterIFC exporterIFC, Element element,
                                                  out string enumTypeValue)
        {
            enumTypeValue = "";
            IFCExportType exportType = IFCExportType.DontExport;

            // Get potential override value first.
            {
                string symbolClassName;

                string exportAsEntity = "IFCExportAs";
                string exportAsType   = "IFCExportType";

                ParameterUtil.GetStringValueFromElementOrSymbol(element, exportAsEntity, out symbolClassName);
                ParameterUtil.GetStringValueFromElementOrSymbol(element, exportAsType, out enumTypeValue);

                if (!String.IsNullOrEmpty(symbolClassName))
                {
                    exportType = ElementFilteringUtil.GetExportTypeFromClassName(symbolClassName);
                    if (exportType != IFCExportType.DontExport)
                    {
                        return(exportType);
                    }
                }
            }

            Category category = element.Category;

            if (category == null)
            {
                return(IFCExportType.DontExport);
            }

            ElementId categoryId = category.Id;

            string ifcClassName = ExporterIFCUtils.GetIFCClassName(element, exporterIFC);

            if (ifcClassName != "")
            {
                enumTypeValue = ExporterIFCUtils.GetIFCType(element, exporterIFC);
                // if using name, override category id if match is found.
                if (!ifcClassName.Equals("Default", StringComparison.OrdinalIgnoreCase))
                {
                    exportType = ElementFilteringUtil.GetExportTypeFromClassName(ifcClassName);
                }
            }

            // if not set, fall back on category id.
            if (exportType == IFCExportType.DontExport)
            {
                //bool exportSeparately = true;
                exportType = ElementFilteringUtil.GetExportTypeFromCategoryId(categoryId, out enumTypeValue /*, out bool exportSeparately*/);
            }

            // if not set, fall back on symbol functions.
            // allow override of IfcBuildingElementProxy.
            if ((exportType == IFCExportType.DontExport) || (exportType == IFCExportType.ExportBuildingElementProxy))
            {
                // TODO: add isColumn.
                //if (familySymbol.IsColumn())
                //exportType = IFCExportType.ExportColumnType;
                //else
                FamilyInstance familyInstance = element as FamilyInstance;
                if (familyInstance != null)
                {
                    switch (familyInstance.StructuralType)
                    {
                    case Autodesk.Revit.DB.Structure.StructuralType.Beam:
                        exportType = IFCExportType.ExportBeam;
                        break;

                    case Autodesk.Revit.DB.Structure.StructuralType.Footing:
                        exportType = IFCExportType.ExportFooting;
                        break;
                    }
                }
            }

            return(exportType);
        }