Пример #1
0
        static void ProcessSchemaFile(string dirLocation, ref HashSet <string> schemaProcessed)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(dirLocation);

            if (dirInfo == null)
            {
                return;
            }

            foreach (FileInfo fileInfo in dirInfo.GetFiles("*.xsd"))
            {
                string schemaId = Path.GetFileNameWithoutExtension(fileInfo.Name);
                if (!schemaProcessed.Contains(fileInfo.Name) && !m_IFCSchemaDict.ContainsKey(schemaId))
                {
                    IfcSchemaEntityTree entityTree = new IfcSchemaEntityTree();
                    bool success = ProcessIFCXMLSchema.ProcessIFCSchema(fileInfo, ref entityTree);
                    if (success)
                    {
                        schemaProcessed.Add(fileInfo.Name);
                        m_IFCSchemaDict.Add(schemaId, entityTree);
                        m_IFCEntityPredefTypeDict.Add(schemaId, entityTree.PredefinedTypeEnumDict);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Get the IFC entity Dictionary for a particular IFC version from the schema file
        /// </summary>
        /// <param name="schemaFile">the schema file name</param>
        /// <returns>the entity Dictionary</returns>
        public static IDictionary <string, IfcSchemaEntityNode> GetEntityDictFor(string schemaFile)
        {
            if (string.IsNullOrEmpty(loadedIfcSchemaVersion) || !loadedIfcSchemaVersion.Equals(schemaFile, StringComparison.InvariantCultureIgnoreCase))
            {
                // Process IFCXml schema here, then search for IfcProduct and build TreeView beginning from that node. Allow checks for the tree nodes. Grey out (and Italic) the abstract entity
                schemaFile = Path.Combine(DirectoryUtil.RevitProgramPath, "EDM\\" + schemaFile);
                FileInfo schemaFileInfo = new FileInfo(schemaFile);
#if IFC_OPENSOURCE
                if (!schemaFileInfo.Exists)
                {
                    // For the open source code, if the schema file is not found, search also from the IfcExporter install folder
                    string schemaLoc = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);
                    schemaFile     = Path.Combine(schemaLoc, schemaFile);
                    schemaFileInfo = new FileInfo(schemaFile);
                }
#endif
                if (schemaFileInfo.Exists)
                {
                    bool newLoad = ProcessIFCXMLSchema.ProcessIFCSchema(schemaFileInfo);
                    if (newLoad)
                    {
                        loadedIfcSchemaVersion = Path.GetFileName(schemaFile);
                    }
                }
            }

            return(EntityDict);
        }
Пример #3
0
        /// <summary>
        /// Get the IFC entity Dictionary for a particular IFC version from the schema file
        /// </summary>
        /// <param name="schemaFile">the schema file name</param>
        /// <returns>the entity Dictionary</returns>
        static IfcSchemaEntityTree PopulateEntityDictFor(string schemaFile)
        {
            IfcSchemaEntityTree entityTree = null;

            // Process IFCXml schema here, then search for IfcProduct and build TreeView beginning from that node. Allow checks for the tree nodes. Grey out (and Italic) the abstract entity
            string   schemaFilePath;
            FileInfo schemaFileInfo;

            string schemaLoc = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);

            schemaFilePath = Path.Combine(schemaLoc, schemaFile + ".xsd");
            schemaFileInfo = new FileInfo(schemaFilePath);
            if (!schemaFileInfo.Exists)
            {
                schemaFilePath = Path.Combine(DirectoryUtil.IFCSchemaLocation, schemaFile + ".xsd");
                schemaFileInfo = new FileInfo(schemaFilePath);
            }

            if (schemaFileInfo.Exists)
            {
                entityTree = new IfcSchemaEntityTree();
                bool success = ProcessIFCXMLSchema.ProcessIFCSchema(schemaFileInfo, ref entityTree);
            }

            return(entityTree);
        }
Пример #4
0
        public static IDictionary <string, IfcSchemaEntityNode> GetEntityDictFor(string schemaFile)
        {
            if (string.IsNullOrEmpty(loadedIfcSchemaVersion) || !loadedIfcSchemaVersion.Equals(schemaFile, StringComparison.InvariantCultureIgnoreCase))
            {
                // Process IFCXml schema here, then search for IfcProduct and build TreeView beginning from that node. Allow checks for the tree nodes. Grey out (and Italic) the abstract entity
                string schemaLoc = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);
                schemaFile = System.IO.Path.Combine(schemaLoc, schemaFile);
                FileInfo schemaFileInfo = new FileInfo(schemaFile);

                bool newLoad = ProcessIFCXMLSchema.ProcessIFCSchema(schemaFileInfo);
                if (newLoad)
                {
                    loadedIfcSchemaVersion = Path.GetFileName(schemaFile);
                }
            }

            return(EntityDict);
        }