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);
        }
Beispiel #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);
        }
Beispiel #3
0
        /// <summary>
        /// Construct a document.
        ///
        /// The document will have all unit types set to SI units.
        /// </summary>
        /// <param name="projectName">The name of the project.</param>
        /// <param name="projectDescription">The description of the project.</param>
        /// <param name="userId">The id of the user.</param>
        /// <param name="userLastName">The last name of the user.</param>
        /// <param name="userFirstName">The first name of the user.</param>
        /// <param name="userEmailAddress">The email address of the user.</param>
        /// <param name="orgName">The user's organization.</param>
        /// <param name="orgDescription">A description of the user's organization.</param>
        /// <param name="addressDescription">A description of the address.</param>
        /// <param name="street">The street.</param>
        /// <param name="city">The city.</param>
        /// <param name="poBox">The PO box.</param>
        /// <param name="state">The state.</param>
        /// <param name="postalCode">The postal code.</param>
        /// <param name="country">The country.</param>
        public Document(string projectName,
                        string projectDescription = null,
                        string userId             = null,
                        string userLastName       = null,
                        string userFirstName      = null,
                        string userEmailAddress   = null,
                        string orgName            = null,
                        string orgDescription     = null,
                        string addressDescription = null,
                        string street             = null,
                        string city       = null,
                        string poBox      = null,
                        string state      = null,
                        string postalCode = null,
                        string country    = null)
        {
            // Create an organization for app creation.
            var appOrg = new IfcOrganization(APPNAME);

            this.AddEntity(appOrg);

            // Create an authoring application.
            var v   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            var app = new IfcApplication(appOrg, v, APPNAME, APPNAME);

            this.AddEntity(app);

            var orgAddress = AddAddress(addressDescription, street, city, poBox, state, postalCode, country);
            var person     = AddPerson(userId, userLastName, userFirstName, userEmailAddress, IfcRoleEnum.ARCHITECT);
            var org        = AddOrganization(orgName, orgDescription, orgAddress);

            // Create an person and history for the owner history.
            var personAndOrg = new IfcPersonAndOrganization(person, org);

            this.AddEntity(personAndOrg);

            // Create an owner history for the project.
            var history = new IfcOwnerHistory(personAndOrg, app, UnixNow());

            this.AddEntity(history);

            var unitAss = AddUnitAssignment();

            var geo = AddGeometricContext();

            // Create the project.
            var proj = new IfcProject(IfcGuid.ToIfcGuid(Guid.NewGuid()), history, projectName, projectDescription, null, null, null, new List <IfcRepresentationContext> {
                geo
            }, unitAss);

            this.AddEntity(proj);
        }
Beispiel #4
0
        public Model(IDictionary <Guid, BaseIfc> storage, string name, string description, IfcAddress address, IfcPerson user, IfcOrganization owner)
        {
            this.storage = storage;

            this.storage.Add(address.Id, address);
            this.storage.Add(user.Id, user);
            this.storage.Add(owner.Id, owner);

            // Create an organization for app creation.
            var appOrg = new IfcOrganization(APPNAME);

            this.storage.Add(appOrg.Id, appOrg);

            // Create an authoring application.
            var v   = owner.GetType().Assembly.GetName().Version.ToString();
            var app = new IfcApplication(appOrg, v, APPNAME, APPNAME);

            this.storage.Add(app.Id, app);

            // Create an person and history for the owner history.
            var personAndOrg = new IfcPersonAndOrganization(user, owner);

            this.storage.Add(personAndOrg.Id, personAndOrg);

            // Create an owner history for the project.
            var history = new IfcOwnerHistory(personAndOrg, app, UnixNow());

            this.storage.Add(history.Id, history);

            var lu = new IfcSIUnit(null, IfcUnitEnum.LENGTHUNIT, IfcSIUnitName.METRE);

            this.storage.Add(lu.Id, lu);
            var lengthUnit = new IfcUnit(lu);

            var au = new IfcSIUnit(null, IfcUnitEnum.AREAUNIT, IfcSIUnitName.SQUARE_METRE);

            this.storage.Add(au.Id, au);
            var areaUnit = new IfcUnit(au);

            var vu = new IfcSIUnit(null, IfcUnitEnum.VOLUMEUNIT, IfcSIUnitName.CUBIC_METRE);

            this.storage.Add(vu.Id, vu);
            var volumeUnit = new IfcUnit(vu);

            var sau = new IfcSIUnit(null, IfcUnitEnum.SOLIDANGLEUNIT, IfcSIUnitName.STERADIAN);

            this.storage.Add(sau.Id, sau);
            var solidAngleUnit = new IfcUnit(sau);

            var mu = new IfcSIUnit(null, IfcUnitEnum.MASSUNIT, IfcSIUnitName.GRAM);

            this.storage.Add(mu.Id, mu);
            var massUnit = new IfcUnit(mu);

            var tu = new IfcSIUnit(null, IfcUnitEnum.TIMEUNIT, IfcSIUnitName.SECOND);

            this.storage.Add(tu.Id, tu);
            var timeUnit = new IfcUnit(tu);

            var thu = new IfcSIUnit(null, IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT, IfcSIUnitName.DEGREE_CELSIUS);

            this.storage.Add(thu.Id, thu);
            var thermUnit = new IfcUnit(thu);

            var lmu = new IfcSIUnit(null, IfcUnitEnum.LUMINOUSINTENSITYUNIT, IfcSIUnitName.LUMEN);

            this.storage.Add(lmu.Id, lmu);
            var lumUnit = new IfcUnit(lmu);

            var pau = new IfcSIUnit(null, IfcUnitEnum.PLANEANGLEUNIT, IfcSIUnitName.RADIAN);

            this.storage.Add(pau.Id, pau);
            var planeAngleUnit = new IfcUnit(pau);

            var measure = new IfcMeasureWithUnit(new IfcValue(new IfcMeasureValue(new IfcPlaneAngleMeasure(1.745e-2))), planeAngleUnit);

            this.storage.Add(measure.Id, measure);

            var dimExp = new IfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0);

            this.storage.Add(dimExp.Id, dimExp);

            var du = new IfcConversionBasedUnit(dimExp, IfcUnitEnum.PLANEANGLEUNIT, "DEGREE", measure);

            this.storage.Add(du.Id, du);
            var degree = new IfcUnit(du);

            var units = new List <IfcUnit> {
                lengthUnit, areaUnit, volumeUnit, solidAngleUnit, massUnit, timeUnit, thermUnit, lumUnit, planeAngleUnit, degree
            };
            var unitAss = new IfcUnitAssignment(units);

            this.storage.Add(unitAss.Id, unitAss);

            // Create the project.
            var proj = new IfcProject(IfcGuid.ToIfcGuid(Guid.NewGuid()), history, name, description, null, null, null, null, unitAss);

            this.storage.Add(proj.Id, proj);
        }
Beispiel #5
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);
        }