Beispiel #1
0
        private void Initialize(string revitBasicFileInfoString)
        {
            if (string.IsNullOrEmpty(revitBasicFileInfoString))
            {
                return;
            }
            //Clear disturbs
            var basicFileInfoString = revitBasicFileInfoString.Replace("\0", string.Empty);
            //Read lines
            var detailInfoLines = basicFileInfoString.Split(new[] { "\r\n" }, new StringSplitOptions());

            foreach (var detailInfoLine in detailInfoLines)
            {
                //Divide by ":"
                var index = detailInfoLine.IndexOf(":", StringComparison.Ordinal);
                if (index < 0)
                {
                    continue;
                }
                var infoKey     = detailInfoLine.Substring(0, index).Trim();
                var fileInfoKey = RevitFileUtils.ResolveFileInfoKey(infoKey);
                if (fileInfoKey == FileInfoKey.Invalid)
                {
                    continue;
                }
                var infoValue = detailInfoLine.Substring(index + 1).Trim();
                FileInfoPair.Add(fileInfoKey, infoValue);
            }
        }
        /// <summary>
        ///     Read the ole structure of the file and save all the streams
        /// </summary>
        /// <returns>A dictionary to reach the content</returns>
        private void GetAllContents()
        {
            //Open the OLE storage of the file
            var storageInfo = OleUtils.InvokeStorageRootMethod(null, "Open", FilePath, FileMode.Open, FileAccess.Read,
                                                               FileShare.Read);

            if (null == storageInfo)
            {
                return;
            }
            try
            {
                SubContents = new Dictionary <FileInfoType, byte[]>();
                //Read all streams from the OLE storage
                var streamInfos = storageInfo.GetStreams();
                foreach (var streamInfo in streamInfos)
                {
                    SubContents.Add(RevitFileUtils.ResolveFileInfoType(streamInfo.Name),
                                    StreamUtils.StreamToBytes(streamInfo.GetStream()));
                }
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                //Close the OLE storage of the file
                OleUtils.InvokeStorageRootMethod(storageInfo, "Close");
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string str = System.AppDomain.CurrentDomain.BaseDirectory;

            Console.WriteLine(str);
            Console.WriteLine(folderPath);
            DirectoryInfo mydir = new DirectoryInfo(folderPath);
            List          files = new List();

            foreach (FileSystemInfo fsi in mydir.GetFileSystemInfos())
            {
                string extension = Path.GetExtension(fsi.ToString());
                if (checkFile(fsi.ToString()))
                {
                    Console.WriteLine(fsi);
                    string building_name = "";
                    foreach (char c in fsi.ToString())
                    {
                        if ((int)c == 46)
                        {
                            break;
                        }
                        building_name += c;
                    }
                    RevitFileUtils file = new RevitFileUtils(folderPath + "/" + fsi.ToString(), building_name);


                    files.Add(file);

                    /*
                     * file.GetVersion();
                     * if (file.getFileVersion() == "2015" || file.getFileVersion() == "2016" || file.getFileVersion() == "2017" || file.getFileVersion() == "2018" || file.getFileVersion() == "2019" || file.getFileVersion() == "2020")
                     * {
                     *  files.Add(file);
                     * }
                     */
                }
            }
            foreach (RevitFileUtils f in files)
            {
                Console.WriteLine(f.getFilePath());
            }
            revitFile r = new revitFile(files);

            r.convertRevitFiles();

            /*
             * revitFile r = new revitFile(filePath);
             * r.convertRevitFile();
             */
        }