Example #1
0
        internal void GenerateExample(string path, ModelView modelView, bool radians)
        {
            DatabaseIfc database = GenerateDatabase(modelView, radians);
            IfcBuilding building = new IfcBuilding(database, "IfcBuilding");

            building.Comments.Add("defines the default building (as required as the minimum spatial element) ");
            database.NextObjectRecord = 20;
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre);

            project.Comments.Add("general entities required for all IFC  sets, defining the context for the exchange");
            database.Factory.SubContext(FactoryIfc.SubContextIdentifier.Body);
            database.NextObjectRecord = 50;
            GenerateInstance(building);
            ReadOnlyCollection <IfcRelDeclares> rds = project.Declares;

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            if (rds.Count > 0)
            {
                rds[0].GlobalId = "1Cjr05W9T0fx0M3_mdVqMd";
            }
            building.GlobalId = "39t4Pu3nTC4ekXYRIHJB9W";
            building.ContainsElements[0].GlobalId = "3Sa3dTJGn0H8TQIGiuGQd5";
            project.GlobalId = "0$WU4A9R19$vKWO$AdOnKA";
            project.IsDecomposedBy[0].GlobalId = "091a6ewbvCMQ2Vyiqspa7a";

            database[50].Comments.Add("Example data for " + this.GetType().Name);
            WriteFile(database, path);
        }
Example #2
0
        internal void GenerateExample(string path, ModelView modelView)
        {
            STPModelData md = new STPModelData(false, modelView);

            md.NextObjectRecord = 50;
            IfcBuilding building = new IfcBuilding(md, "IfcBuilding")
            {
                GlobalId = "39t4Pu3nTC4ekXYRIHJB9W"
            };

            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, "IfcProject", GGYM.Units.Length.mm)
            {
                GlobalId = "0$WU4A9R19$vKWO$AdOnKA"
            };

            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);
        }
Example #3
0
 protected abstract void GenerateInstance(IfcBuilding building);
Example #4
0
 protected virtual void GenerateData(STPModelData md, IfcBuilding building)
 {
 }
Example #5
0
 protected virtual void GenerateData(DatabaseIfc database, IfcBuilding building)
 {
 }
Example #6
0
        internal void GenerateExample(string path, ModelView modelView)
        {
            DatabaseIfc database = new DatabaseIfc(false, modelView);

            database.Factory.Options.GenerateOwnerHistory = false;
            database.NextObjectRecord = 10;
            IfcBuilding building = new IfcBuilding(database, "IfcBuilding")
            {
                GlobalId = "39t4Pu3nTC4ekXYRIHJB9W"
            };

            building.ContainsElements[0].GlobalId = "3Sa3dTJGn0H8TQIGiuGQd5";
            building.Comments.Add("defines the default building (as required as the minimum spatial element) ");
            database.NextObjectRecord = 20;
            IfcProject project = new IfcProject(building, "IfcProject", IfcUnitAssignment.Length.Millimetre)
            {
                GlobalId = "0$WU4A9R19$vKWO$AdOnKA"
            };

            project.IsDecomposedBy[0].GlobalId = "091a6ewbvCMQ2Vyiqspa7a";
            project.Comments.Add("general entities required for all IFC data sets, defining the context for the exchange");
            database.Factory.SubContext(FactoryIfc.SubContextIdentifier.Body);
            database.NextObjectRecord = 50;
            GenerateData(database, building);
            List <IfcRelDeclares> rds = project.Declares;

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            if (rds.Count > 0)
            {
                rds[0].GlobalId = "1Cjr05W9T0fx0M3_mdVqMd";
            }

            database[50].Comments.Add("Example data for " + this.GetType().Name);


            string filePath = Path.Combine(path, this.GetType().Name + ".ifc");

            if (File.Exists(filePath))
            {
                string[]      newLines      = database.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;
                    int  icounter  = 0;
                    for (; icounter < newLines.Length; icounter++)
                    {
                        string s1 = newLines[icounter];
                        if (s1.StartsWith("FILE_SCHEMA"))
                        {
                            break;
                        }
                    }
                    for (; 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;
                    }
                }
            }
            database.WriteFile(filePath);
        }