Ejemplo n.º 1
0
        private void Intialize()
        {
            Version = new IfVersion(this);
            if (IfBuildings != null)
            {
                return;                      //check if there is already buildings return
            }
            IfBuildings = IfBuilding.GetBuildings(this);

            IfUnit = new IfUnit(this);
        }
Ejemplo n.º 2
0
        public static List <IfBuilding> GetBuildings(IfModel ifModel)
        {
            List <IfBuilding> ifBuildings = new List <IfBuilding>();
            IfBuilding        ifBuidling;

            foreach (var building in ifModel.IfcStore.Instances.OfType <IIfcBuilding>())
            {
                ifBuidling = new IfBuilding(ifModel)
                {
                    IfcBuilding = building,
                    IfModel     = ifModel
                };
                ifBuildings.Add(ifBuidling);
            }

            return(ifBuildings);
        }
Ejemplo n.º 3
0
        public static IfModel New(string projectName, string buildingName, bool save, string filepath = "Untitled")
        {
            //first we need to set up some credentials for ownership of data in the new model
            var credentials = new XbimEditorCredentials
            {
                ApplicationDevelopersName = "ITI ",
                ApplicationFullName       = " ",
                ApplicationIdentifier     = " ",
                ApplicationVersion        = "1.0",
                EditorsFamilyName         = "ITI ",
                EditorsGivenName          = "ITI ",
                EditorsOrganisationName   = " ITI"
            };
            //now we can create an IfcStore, it is in Ifc4 format and will be held in memory rather than in a database
            //database is normally better in performance terms if the model is large >50MB of Ifc or if robust transactions are required

            var     model   = IfcStore.Create(credentials, IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel);
            IfModel ifModel = new IfModel(model);

            //Begin a transaction as all changes to a model are ACID
            using (var txn = model.BeginTransaction("Initialise Model"))
            {
                //create a project
                var project = model.Instances.New <IfcProject>();

                //set the units to SI (mm and metres)
                project.Initialize(ProjectUnits.SIUnitsUK);
                project.Name = projectName;
                //now commit the changes, else they will be rolled back at the end of the scope of the using statement
                txn.Commit();
            }
            if (save)
            {
                model.SaveAs(filepath);
            }

            ifModel.IfBuildings.Add(IfBuilding.New(ifModel, buildingName));

            return(ifModel);
        }
Ejemplo n.º 4
0
        public static IfBuilding New(IfModel ifModel, string name)
        {
            IfBuilding ifBuilding = new IfBuilding();
            var        model      = ifModel.IfcStore;

            using (var txn = model.BeginTransaction("Create Building"))
            {
                var building = model.Instances.New <IfcBuilding>();
                building.Name            = name;
                building.CompositionType = IfcElementCompositionEnum.ELEMENT;
                var localPlacement = model.Instances.New <IfcLocalPlacement>();
                building.ObjectPlacement = localPlacement;
                var placement = model.Instances.New <IfcAxis2Placement3D>();
                localPlacement.RelativePlacement = placement;
                placement.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(0, 0, 0));
                var project = model.Instances.OfType <IfcProject>().FirstOrDefault();
                project?.AddBuilding(building);
                txn.Commit();
                //set the Ifcbuilding
                ifBuilding.IfcBuilding = building;
            }
            return(ifBuilding);
        }