/// <summary>
        /// Gets export type from IFC class name.
        /// </summary>
        /// <param name="originalIFCClassName">The IFC class name.</param>
        /// <returns>The export type.</returns>
        public static IFCExportInfoPair GetExportTypeFromClassName(String originalIFCClassName)
        {
            IFCExportInfoPair exportInfoPair = new IFCExportInfoPair();

            string cleanIFCClassName = originalIFCClassName.Trim();

            if (cleanIFCClassName.StartsWith("Ifc", true, null))
            {
                // Here we try to catch any possible types that are missing above by checking both the class name or the type name
                // Unless there is any special treatment needed most of the above check can be done here
                string clName = cleanIFCClassName.Substring(cleanIFCClassName.Length - 4, 4).Equals("Type", StringComparison.CurrentCultureIgnoreCase) ?
                                cleanIFCClassName.Substring(0, cleanIFCClassName.Length - 4) :
                                cleanIFCClassName;

                // Deal with small number of IFC2x3/IFC4 types that have changed in a hardwired way.
                if (ExporterCacheManager.ExportOptionsCache.ExportAsOlderThanIFC4)
                {
                    if (string.Compare(clName, "IfcBurner", true) == 0)
                    {
                        exportInfoPair.SetValueWithPair(IFCEntityType.IfcGasTerminalType);
                    }
                    else if (string.Compare(clName, "IfcElectricDistributionBoard", true) == 0)
                    {
                        exportInfoPair.SetValueWithPair(IFCEntityType.IfcElectricDistributionPoint);
                    }
                    else
                    {
                        exportInfoPair.SetValueWithPair(clName);
                    }
                }
                else
                {
                    if (string.Compare(clName, "IfcGasTerminal", true) == 0)
                    {
                        exportInfoPair.SetValueWithPair(IFCEntityType.IfcBurnerType);
                    }
                    else if (string.Compare(clName, "IfcElectricDistributionPoint", true) == 0)
                    {
                        exportInfoPair.SetValueWithPair(IFCEntityType.IfcElectricDistributionBoardType);
                    }
                    else if (string.Compare(clName, "IfcElectricHeater", true) == 0)
                    {
                        exportInfoPair.SetValueWithPair(IFCEntityType.IfcSpaceHeaterType);
                    }
                    else
                    {
                        exportInfoPair.SetValueWithPair(clName);
                    }
                }

                if (exportInfoPair.ExportInstance == IFCEntityType.UnKnown)
                {
                    exportInfoPair.SetValueWithPair(IFCEntityType.IfcBuildingElementProxy);
                }
            }

            exportInfoPair.ValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedType("NOTDEFINED", exportInfoPair.ExportType.ToString());

            return(exportInfoPair);
        }
      /// <summary>
      /// Gets export type from IFC class name.
      /// </summary>
      /// <param name="originalIFCClassName">The IFC class name.</param>
      /// <returns>The export type.</returns>
      public static IFCExportInfoPair GetExportTypeFromClassName(String originalIFCClassName)
      {
         IFCExportInfoPair exportInfoPair = new IFCExportInfoPair();

         string cleanIFCClassName = originalIFCClassName.Trim().ToUpper();
         if (cleanIFCClassName.StartsWith("IFC"))
         {
            // Here we try to catch any possible types that are missing above by checking both the class name or the type name
            // Unless there is any special treatment needed most of the above check can be done here
            string clName = cleanIFCClassName.Substring(cleanIFCClassName.Length - 4, 4).Equals("Type", StringComparison.CurrentCultureIgnoreCase) ?
               cleanIFCClassName.Substring(0, cleanIFCClassName.Length - 4) :
               cleanIFCClassName;

            // Deal with small number of IFC2x3/IFC4 types that have changed in a hardwired way.
            if (ExporterCacheManager.ExportOptionsCache.ExportAsOlderThanIFC4)
            {
               if (PreIFC4Remap.TryGetValue(clName, out IFCEntityType ifcEntityType))
                  exportInfoPair.SetValueWithPair(ifcEntityType);
               else
                  exportInfoPair.SetValueWithPair(clName);
            }
            else
            {
               if (IFC4Remap.TryGetValue(clName, out IFCEntityType ifcEntityType))
                  exportInfoPair.SetValueWithPair(ifcEntityType);
               else
                  exportInfoPair.SetValueWithPair(clName);
            }

            if (exportInfoPair.ExportInstance == IFCEntityType.UnKnown)
               exportInfoPair.SetValueWithPair(IFCEntityType.IfcBuildingElementProxy);
         }

         exportInfoPair.ValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedType("NOTDEFINED", exportInfoPair.ExportType.ToString());

         return exportInfoPair;
      }
Beispiel #3
0
        // TODO: implement  out bool exportSeparately
        /// <summary>
        /// Gets export type from category id.
        /// </summary>
        /// <param name="categoryId">The category id.</param>
        /// <param name="ifcEnumType">The string value represents the IFC type.</param>
        /// <returns>The export type.</returns>
        public static IFCExportInfoPair GetExportTypeFromCategoryId(ElementId categoryId, out string ifcEnumType /*, out bool exportSeparately*/)
        {
            IFCExportInfoPair exportInfoPair = new IFCExportInfoPair();

            ifcEnumType = "NOTDEFINED";
            //exportSeparately = true;

            if (categoryId == new ElementId(BuiltInCategory.OST_Cornices))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcBeam;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Ceilings))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcCovering;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_CurtainWallPanels))
            {
                ifcEnumType = "CURTAIN_PANEL";
                //exportSeparately = false;
                exportInfoPair.ExportInstance = IFCEntityType.IfcPlate;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Doors))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcDoor;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Furniture))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcFurniture;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Floors))
            {
                ifcEnumType = "FLOOR";
                exportInfoPair.ExportInstance = IFCEntityType.IfcSlab;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_IOSModelGroups))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcGroup;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Mass))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcBuildingElementProxy;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_CurtainWallMullions))
            {
                ifcEnumType = "MULLION";
                //exportSeparately = false;
                exportInfoPair.ExportInstance = IFCEntityType.IfcMember;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Railings))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcRailing;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Ramps))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcRamp;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Roofs))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcRoof;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Site))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcSite;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Stairs))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcStair;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Walls))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcWall;
            }
            else if (categoryId == new ElementId(BuiltInCategory.OST_Windows))
            {
                exportInfoPair.ExportInstance = IFCEntityType.IfcWindow;
            }

            // Get the associated Type pair if it is a valid entity
            if (exportInfoPair.ExportInstance != IFCEntityType.UnKnown)
            {
                string typeName = exportInfoPair.ExportInstance.ToString() + "Type";
                exportInfoPair.ExportType = GetValidIFCEntityType(typeName);
                exportInfoPair.ValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedType(ifcEnumType, exportInfoPair.ExportType.ToString());
            }

            return(exportInfoPair);
        }
Beispiel #4
0
        /// <summary>
        /// Gets export type from IFC class name.
        /// </summary>
        /// <param name="ifcClassName">The IFC class name.</param>
        /// <returns>The export type.</returns>
        public static IFCExportInfoPair GetExportTypeFromClassName(String ifcClassName)
        {
            IFCExportInfoPair exportInfoPair = new IFCExportInfoPair();

            if (ifcClassName.StartsWith("Ifc", true, null))
            {
                // Here we try to catch any possible types that are missing above by checking both the class name or the type name
                // Unless there is any special treatment needed most of the above check can be done here
                string clName = ifcClassName.Substring(ifcClassName.Length - 4, 4).Equals("Type", StringComparison.CurrentCultureIgnoreCase) ? ifcClassName.Substring(0, ifcClassName.Length - 4) : ifcClassName;
                string tyName = null;
                if (((ExporterCacheManager.ExportOptionsCache.ExportAs2x2 || ExporterCacheManager.ExportOptionsCache.ExportAs2x3)) &&
                    (clName.Equals("IfcDoor", StringComparison.InvariantCultureIgnoreCase) || clName.Equals("ifcWindow", StringComparison.InvariantCultureIgnoreCase)))
                {
                    // Prior to IFC4 Door and Window types are not "Ifc..Type", but "Ifc.. Style"
                    tyName = clName + "Style";
                }
                else
                {
                    tyName = clName + "Type";
                }

                IFCEntityType theGenExportClass;
                IFCEntityType theGenExportType;
                var           ifcEntitySchemaTree = IfcSchemaEntityTree.GetEntityDictFor(ExporterCacheManager.ExportOptionsCache.FileVersion);
                if (ifcEntitySchemaTree == null || ifcEntitySchemaTree.Count == 0)
                {
                    throw new Exception("Unable to locate IFC Schema xsd file! Make sure the relevant xsd " + ExporterCacheManager.ExportOptionsCache.FileVersion + " exists.");
                }

                bool clNameValid = false;
                bool tyNameValid = false;

                // Deal with small number of IFC2x3/IFC4 types that have changed in a hardwired way.
                if (ExporterCacheManager.ExportOptionsCache.ExportAsOlderThanIFC4)
                {
                    if (string.Compare(clName, "IfcBurner", true) == 0)
                    {
                        clName = "IfcFlowTerminal";
                        tyName = "IfcGasTerminalType";
                    }
                    else if (string.Compare(clName, "IfcElectricDistributionBoard", true) == 0)
                    {
                        clName = "IfcElectricDistributionPoint";
                        tyName = "";
                    }
                }
                else
                {
                    if (string.Compare(clName, "IfcGasTerminal", true) == 0)
                    {
                        clName = "IfcBurner";
                        tyName = "IfcBurnerType";
                    }
                    else if (string.Compare(clName, "IfcElectricDistributionPoint", true) == 0)
                    {
                        clName = "IfcElectricDistributionBoard";
                        tyName = "IfcElectricDistributionBoardType";
                    }
                    else if (string.Compare(clName, "IfcElectricHeater", true) == 0)
                    {
                        clName = "IfcSpaceHeater";
                        tyName = "IfcSpaceHeaterType";
                    }
                }

                IfcSchemaEntityNode clNode = IfcSchemaEntityTree.Find(clName);
                if (clNode != null)
                {
                    clNameValid = IfcSchemaEntityTree.IsSubTypeOf(clName, "IfcProduct") && !clNode.isAbstract;
                }

                IfcSchemaEntityNode tyNode = IfcSchemaEntityTree.Find(tyName);
                if (tyNode != null)
                {
                    tyNameValid = IfcSchemaEntityTree.IsSubTypeOf(tyName, "IfcTypeProduct") && !tyNode.isAbstract;
                }

                if (tyNameValid)
                {
                    if (IFCEntityType.TryParse(tyNode.Name, out theGenExportType))
                    {
                        exportInfoPair.ExportType = theGenExportType;
                    }
                }

                if (clNameValid)
                {
                    if (IFCEntityType.TryParse(clNode.Name, out theGenExportClass))
                    {
                        exportInfoPair.ExportInstance = theGenExportClass;
                    }
                }
                // If the instance is not valid, but the type is valid, try find the paired instance supertype that is not Abstract type
                else if (tyNameValid)
                {
                    IfcSchemaEntityNode compatibleInstance = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(tyName);
                    if (compatibleInstance != null)
                    {
                        if (IFCEntityType.TryParse(compatibleInstance.Name, out theGenExportClass))
                        {
                            exportInfoPair.ExportInstance = theGenExportClass;
                        }
                    }
                }

                // This used to throw an exception, but this could abort export if the user enters a bad IFC class name
                // in the ExportLayerOptions table.  In the future, we should log this.
                //throw new Exception("IFC: Unknown IFC type in getExportTypeFromClassName: " + ifcClassName);
                //return IFCExportType.IfcBuildingElementProxyType;

                if (exportInfoPair.ExportInstance == IFCEntityType.UnKnown)
                {
                    exportInfoPair.ExportInstance = IFCEntityType.IfcBuildingElementProxy;
                }
            }

            //return IFCExportType.DontExport;
            exportInfoPair.ValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedType("NOTDEFINED", exportInfoPair.ExportType.ToString());

            return(exportInfoPair);
        }