示例#1
0
        /// <summary>
        /// Initialize the class with the entity and the type
        /// </summary>
        /// <param name="instance">the entity</param>
        /// <param name="type">the type</param>
        public IFCExportInfoPair(IFCEntityType instance, IFCEntityType type, string predefinedType)
        {
            instance         = ElementFilteringUtil.GetValidIFCEntityType(instance);
            m_ExportInstance = instance;

            type         = ElementFilteringUtil.GetValidIFCEntityType(type);
            m_ExportType = type;

            ValidatedPredefinedType = predefinedType;
        }
示例#2
0
        /// <summary>
        /// Initialize the class with the entity and the type
        /// </summary>
        /// <param name="instance">the entity</param>
        /// <param name="type">the type</param>
        public IFCExportInfoPair(IFCEntityType instance, IFCEntityType type, string predefinedType)
        {
            instance       = ElementFilteringUtil.GetValidIFCEntityType(instance);
            ExportInstance = instance;

            type       = ElementFilteringUtil.GetValidIFCEntityType(type);
            ExportType = type;

            if (!string.IsNullOrEmpty(predefinedType))
            {
                ValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedTypeType(predefinedType, null, ExportInstance.ToString());
                if (string.IsNullOrEmpty(ValidatedPredefinedType))
                {
                    ValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedTypeType(predefinedType, "NOTDEFINED", ExportType.ToString());
                }
            }
        }
示例#3
0
        /// <summary>
        /// Initialize the class with the entity and the type
        /// </summary>
        /// <param name="instance">the entity</param>
        /// <param name="type">the type</param>
        public IFCExportInfoPair(IFCEntityType instance, IFCEntityType type, string predefinedType)
        {
            instance       = ElementFilteringUtil.GetValidIFCEntityType(instance);
            ExportInstance = instance;

            type       = ElementFilteringUtil.GetValidIFCEntityType(type);
            ExportType = type;

            if (!string.IsNullOrEmpty(predefinedType))
            {
                string newValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedTypeType(predefinedType, ValidatedPredefinedType, ExportInstance.ToString());
                if (ExporterUtil.IsNotDefined(newValidatedPredefinedType))
                {
                    newValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedTypeType(predefinedType, ValidatedPredefinedType, ExportType.ToString());
                }
                ValidatedPredefinedType = newValidatedPredefinedType;
            }
        }
示例#4
0
        /// <summary>
        /// Initialize the class with the entity and the type
        /// </summary>
        /// <param name="instance">the entity</param>
        /// <param name="type">the type</param>
        public IFCExportInfoPair(IFCEntityType instance, IFCEntityType type, string predefinedType)
        {
            instance         = ElementFilteringUtil.GetValidIFCEntityType(instance);
            m_ExportInstance = instance;

            type         = ElementFilteringUtil.GetValidIFCEntityType(type);
            m_ExportType = type;

            ValidatedPredefinedType = predefinedType;
            //if (!string.IsNullOrEmpty(predefinedType))
            //{
            //   string newValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedTypeType(predefinedType, m_ValidatedPredefinedType, m_ExportInstance.ToString());
            //   if (ExporterUtil.IsNotDefined(newValidatedPredefinedType))
            //      newValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedTypeType(predefinedType, m_ValidatedPredefinedType, m_ExportType.ToString());
            //   m_ValidatedPredefinedType = newValidatedPredefinedType;
            //}
            //else
            //   m_ValidatedPredefinedType = IFCValidateEntry.GetValidIFCPredefinedTypeType("NOTDEFINED", m_ValidatedPredefinedType, m_ExportType.ToString());
        }
示例#5
0
        /// <summary>
        /// Set the pair information using only either the entity or the type
        /// </summary>
        /// <param name="entityTypeStr">the entity or type string</param>
        /// <param name="predefineType">predefinedtype string</param>
        public void SetValueWithPair(string entityTypeStr, string predefineType = null)
        {
            int  typeLen = 4;
            bool isType  = entityTypeStr.Substring(entityTypeStr.Length - 4, 4).Equals("Type", StringComparison.CurrentCultureIgnoreCase);

            if (!isType)
            {
                if (entityTypeStr.Equals("IfcDoorStyle", StringComparison.InvariantCultureIgnoreCase) ||
                    entityTypeStr.Equals("IfcWindowStyle", StringComparison.InvariantCultureIgnoreCase))
                {
                    isType  = true;
                    typeLen = 5;
                }
            }

            if (isType)
            {
                // Get the instance
                string instName          = entityTypeStr.Substring(0, entityTypeStr.Length - typeLen);
                IfcSchemaEntityNode node = IfcSchemaEntityTree.Find(instName);
                if (node != null && !node.isAbstract)
                {
                    IFCEntityType instType = IFCEntityType.UnKnown;
                    if (IFCEntityType.TryParse(instName, true, out instType))
                    {
                        m_ExportInstance = instType;
                    }
                }
                else
                {
                    // If not found, try non-abstract supertype derived from the type
                    node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(instName);
                    if (node != null)
                    {
                        IFCEntityType instType = IFCEntityType.UnKnown;
                        if (IFCEntityType.TryParse(node.Name, true, out instType))
                        {
                            m_ExportInstance = instType;
                        }
                    }
                }

                // set the type
                IFCEntityType entityType = ElementFilteringUtil.GetValidIFCEntityType(entityTypeStr);
                if (entityType != IFCEntityType.UnKnown)
                {
                    m_ExportType = entityType;
                }
                else
                {
                    node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(entityTypeStr);
                    if (node != null)
                    {
                        IFCEntityType instType = IFCEntityType.UnKnown;
                        if (IFCEntityType.TryParse(node.Name, true, out instType))
                        {
                            m_ExportType = instType;
                        }
                    }
                }
            }
            else
            {
                // set the instance
                IFCEntityType instType = ElementFilteringUtil.GetValidIFCEntityType(entityTypeStr);
                if (instType != IFCEntityType.UnKnown)
                {
                    m_ExportInstance = instType;
                }
                else
                {
                    // If not found, try non-abstract supertype derived from the type
                    IfcSchemaEntityNode node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(entityTypeStr);
                    if (node != null)
                    {
                        instType = IFCEntityType.UnKnown;
                        if (IFCEntityType.TryParse(node.Name, true, out instType))
                        {
                            m_ExportInstance = instType;
                        }
                    }
                }

                // set the type pair
                string typeName = entityTypeStr;
                if (ExporterCacheManager.ExportOptionsCache.ExportAsOlderThanIFC4 &&
                    (entityTypeStr.Equals("IfcDoor", StringComparison.InvariantCultureIgnoreCase) ||
                     entityTypeStr.Equals("IfcWindow", StringComparison.InvariantCultureIgnoreCase)))
                {
                    typeName += "Style";
                }
                else
                {
                    typeName += "Type";
                }

                IFCEntityType entityType = ElementFilteringUtil.GetValidIFCEntityType(typeName);
                if (entityType != IFCEntityType.UnKnown)
                {
                    m_ExportType = entityType;
                }
                else
                {
                    // If the type name is not found, likely it does not have the pair at this level, needs to get the supertype of the instance to get the type pair
                    IList <IfcSchemaEntityNode> instNodes = IfcSchemaEntityTree.FindAllSuperTypes(entityTypeStr, "IfcProduct", "IfcGroup");
                    foreach (IfcSchemaEntityNode instNode in instNodes)
                    {
                        typeName = instNode.Name + "Type";
                        IfcSchemaEntityNode node = IfcSchemaEntityTree.Find(typeName);
                        if (node == null)
                        {
                            node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(typeName);
                        }

                        if (node != null && !node.isAbstract)
                        {
                            instType = IFCEntityType.UnKnown;
                            if (IFCEntityType.TryParse(node.Name, true, out instType))
                            {
                                m_ExportType = instType;
                                break;
                            }
                        }
                    }
                }
            }

            ValidatedPredefinedType = predefineType;
        }
示例#6
0
        /// <summary>
        /// Set the pair information using only either the entity or the type
        /// </summary>
        /// <param name="entityType">the entity or type</param>
        public void SetValueWithPair(IFCEntityType entityType)
        {
            string entityTypeStr = entityType.ToString();
            bool   isType        = entityTypeStr.Substring(entityTypeStr.Length - 4, 4).Equals("Type", StringComparison.CurrentCultureIgnoreCase);

            if (isType)
            {
                // Get the instance
                string instName          = entityTypeStr.Substring(0, entityTypeStr.Length - 4);
                IfcSchemaEntityNode node = IfcSchemaEntityTree.Find(instName);
                if (node != null && !node.isAbstract)
                {
                    IFCEntityType instType = IFCEntityType.UnKnown;
                    if (IFCEntityType.TryParse(instName, out instType))
                    {
                        ExportInstance = instType;
                    }
                }
                // If not found, try non-abstract supertype derived from the type
                node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(instName);
                if (node != null)
                {
                    IFCEntityType instType = IFCEntityType.UnKnown;
                    if (IFCEntityType.TryParse(node.Name, out instType))
                    {
                        ExportInstance = instType;
                    }
                }

                // set the type
                entityType = ElementFilteringUtil.GetValidIFCEntityType(entityType);
                if (entityType != IFCEntityType.UnKnown)
                {
                    ExportType = entityType;
                }
                else
                {
                    node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(entityTypeStr);
                    if (node != null)
                    {
                        IFCEntityType instType = IFCEntityType.UnKnown;
                        if (IFCEntityType.TryParse(node.Name, out instType))
                        {
                            ExportType = instType;
                        }
                    }
                }
            }
            else
            {
                // set the instance
                entityType = ElementFilteringUtil.GetValidIFCEntityType(entityType);
                if (entityType != IFCEntityType.UnKnown)
                {
                    ExportInstance = entityType;
                }
                else
                {
                    // If not found, try non-abstract supertype derived from the type
                    IfcSchemaEntityNode node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(entityTypeStr);
                    if (node != null)
                    {
                        IFCEntityType instType = IFCEntityType.UnKnown;
                        if (IFCEntityType.TryParse(node.Name, out instType))
                        {
                            ExportInstance = instType;
                        }
                    }
                }

                // set the type pair
                string typeName = entityType.ToString() + "Type";
                entityType = ElementFilteringUtil.GetValidIFCEntityType(typeName);
                if (entityType != IFCEntityType.UnKnown)
                {
                    ExportType = entityType;
                }
                else
                {
                    IfcSchemaEntityNode node = IfcSchemaEntityTree.FindNonAbsInstanceSuperType(typeName);
                    if (node != null)
                    {
                        IFCEntityType instType = IFCEntityType.UnKnown;
                        if (IFCEntityType.TryParse(node.Name, out instType))
                        {
                            ExportType = instType;
                        }
                    }
                }
            }
        }