Example #1
0
        internal void GenerateExample(string path, ModelView modelView)
        {
            STPModelData md = new STPModelData(false, modelView);

            md.NextObjectRecord = 50;
            IfcBuilding building = new IfcBuilding(md, "39t4Pu3nTC4ekXYRIHJB9W", "IfcBuilding", null, "");

            building.ContainsElements[0].GlobalId = "3Sa3dTJGn0H8TQIGiuGQd5";
            building.Comments.Add("defines the default building (as required as the minimum spatial element) ");
            md.NextObjectRecord = 100;
            IfcProject project = new IfcProject(building, "0$WU4A9R19$vKWO$AdOnKA", "IfcProject", "", "", null, GGYM.Units.Length.mm);

            project.IsDecomposedBy[0].GlobalId = "091a6ewbvCMQ2Vyiqspa7a";
            project.RepresentationContexts[0].Comments.Add("general entities required for all IFC data sets, defining the context for the exchange");
            md.NextObjectRecord = 200;
            GenerateData(md, building);
            string filePath = Path.Combine(path, this.GetType().Name + ".ifc");

            if (File.Exists(filePath))
            {
                string[]      newLines      = md.ToString().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                List <string> existingLines = new List <string>(File.ReadAllLines(filePath));
                existingLines.RemoveAll(x => string.IsNullOrEmpty(x));

                if (newLines.Length == existingLines.Count)
                {
                    bool identical = true;
                    for (int icounter = 0; icounter < newLines.Length; icounter++)
                    {
                        string s1 = newLines[icounter], s2 = existingLines[icounter];
                        if (s1.StartsWith("/* time_stamp */ ") && s2.StartsWith("/* time_stamp */ "))
                        {
                            continue;
                        }
                        if (string.Compare(s1, s2, true) != 0)
                        {
                            identical = false;
                            break;
                        }
                    }
                    if (identical)
                    {
                        return;
                    }
                }
            }
            md.writeFile(filePath);
        }