Ejemplo n.º 1
0
        public List <string> GetData(IFCDatabase db)
        {
            Dictionary <string, string> objDict = new Dictionary <string, string>();

            foreach (BsonDocument obj in db.IFCModel.FindAll())
            {
                objDict.Add(obj["P21Id"].AsString, new IFCObject(obj).ToIFCString());
            }

            foreach (var pair in ReplaceTable)
            {
                string data = objDict[pair.Key];
                data = data.Substring(data.IndexOf('=') + 1, data.IndexOf(';') - data.IndexOf('='));
                foreach (string replaceId in pair.Value)
                {
                    objDict.Add(replaceId, $"{replaceId}={data}");
                }
            }

            Dictionary <int, string> sortData = objDict.ToDictionary(o => int.Parse(o.Key.Replace("#", "")), p => p.Value);

            sortData = sortData.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);
            List <string> res = new List <string>()
            {
                $"DATA;"
            };

            foreach (string data in sortData.Values)
            {
                res.Add($"{data}");
            }
            res.Add("ENDSEC;");
            res.Add("END-ISO-10303-21;");
            return(res);
        }
Ejemplo n.º 2
0
        public List <string> GetIFCFileString(IFCDatabase db)
        {
            List <string> res = new List <string>();

            res.Add("ISO-10303-21;");
            res.Add(GetHeaderData(db));
            res.AddRange(GetData(db));
            return(res);
        }
Ejemplo n.º 3
0
        public string GetHeaderData(IFCDatabase db)
        {
            string    space  = "\r\n";
            string    res    = $"HEADER;{space}";
            IFCHeader des    = new IFCHeader(db.IFCHead.FindOne(x => x["EntityName"] == "FILE_DESCRIPTION"));
            IFCHeader name   = new IFCHeader(db.IFCHead.FindOne(x => x["EntityName"] == "FILE_NAME"));
            IFCHeader schema = new IFCHeader(db.IFCHead.FindOne(x => x["EntityName"] == "FILE_SCHEMA"));

            return(res + des.ToIFCString() + space + name.ToIFCString() + space + schema.ToIFCString() + space + "ENDSEC;" + space);
        }
Ejemplo n.º 4
0
 public IFCExport(string folderPath, string fileName, IFCDatabase db)
 {
     GetReplaceData(db);
     using (StreamWriter sw = new StreamWriter($"{folderPath}\\{fileName}.ifc", false))
     {
         foreach (string data in GetIFCFileString(db))
         {
             sw.WriteLine(data);
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 取得Replace Table資料
 /// </summary>
 /// <param name="db"></param>
 public void GetReplaceData(IFCDatabase db)
 {
     ReplaceTable = new Dictionary <string, List <string> >();
     foreach (IFCReplaceRecord data in db.ReplaceTable.FindAll())
     {
         if (ReplaceTable.ContainsKey(data.ValueElement))
         {
             ReplaceTable[data.ValueElement].Add(data.KeyElement);
         }
         else
         {
             ReplaceTable.Add(data.ValueElement, new List <string>()
             {
                 data.KeyElement
             });
         }
     }
 }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog file = new OpenFileDialog();

            file.Title  = "Load IFC File";
            file.Filter = "ifc file (*.ifc)|*.ifc";

            if (file.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = file.FileName;

                IFCDatabase ifcDB = IFCDatabase.Instance;
                //ifcDB.initDB(@"E:\JingYing\IFCPlatform\IFCLib\TestDB\TestDB.db");
                System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
                sw.Reset();
                sw.Start();
                richTextBox1.Text = ifcDB.loadIFCFile(file.FileName, "TestIFC");
                sw.Stop();
                richTextBox1.Text += "\r\n共花費:" + sw.Elapsed.TotalMilliseconds.ToString() + "毫秒";
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 新建一個Update物件
 /// </summary>
 /// <param name="Database"></param>
 public IFCUpdate(IFCDatabase Database)
 {
     this.Database = Database;
 }
Ejemplo n.º 8
0
 public IFCQuery(IFCDatabase db)
 {
     Database = db;
 }
Ejemplo n.º 9
0
 public IFCDelete(IFCDatabase Database)
 {
     this.Database = Database;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Create new IFCLiteDrive.
 /// </summary>
 /// <param name="dbPath">Path of LiteDB.</param>
 /// <param name="version">Version of IFC file.</param>
 /// <param name="create">If create index.</param>
 public IFCLiteDrive(string dbPath, IFCVersion version, bool create)
 {
     SchemaReader = new SchemaReader(version);
     IFCDatabase  = new IFCDatabase(dbPath, create);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Database disconnect.
 /// </summary>
 public void Close()
 {
     IFCDatabase.Close();
 }
Ejemplo n.º 12
0
 public IFCInsert(IFCDatabase Database)
 {
     this.Database = Database;
 }