Exemplo n.º 1
0
 public static void AddBuilding(this IfcSite site, IfcBuilding building)
 {
     IEnumerable<IfcRelDecomposes> decomposition = site.IsDecomposedBy;
     if (decomposition.Count() == 0) //none defined create the relationship
     {
         IfcRelAggregates relSub = site.ModelOf.Instances.New<IfcRelAggregates>();
         relSub.RelatingObject = site;
         relSub.RelatedObjects.Add_Reversible(building);
     }
     else
     {
         decomposition.First().RelatedObjects.Add_Reversible(building);
     }
 }
Exemplo n.º 2
0
        public void AddBuilding(IfcBuilding building)
        {
            var decomposition = IsDecomposedBy.FirstOrDefault();

            if (decomposition == null) //none defined create the relationship
            {
                var relSub = Model.Instances.New <IfcRelAggregates>();
                relSub.RelatingObject = this;
                relSub.RelatedObjects.Add(building);
            }
            else
            {
                decomposition.RelatedObjects.Add(building);
            }
        }
Exemplo n.º 3
0
 private IfcBuilding AddBuilding(XbimModel model, IfcBuilding _building)
 {
     using (XbimReadWriteTransaction txn = model.BeginTransaction("Add Building"))
     {
         //var building = model.Instances.New<IfcBuilding>();
         //var building = model.InsertCopy<IfcBuilding>(_building, txn);
         //_building.Bind
         model.IfcProject.AddBuilding(_building);
         //validate and commit changes
         if (model.Validate(txn.Modified(), Console.Out) == 0)
         {
             txn.Commit();
             return _building;
         }
     }
     return null;
 }
Exemplo n.º 4
0
        private void AddProductInBuilding(XbimModel model, IfcBuilding _building, IfcProduct _prod)
        {
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Add Product"))
            {
                //if (_prod is IfcSpatialStructureElement)
                try
                {
                    _building.AddElement(_prod);
                    txn.Commit();
                }
                catch
                {
                    //MessageBox.Show(_prod.GetType().Name);
                }

            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Copy building
        /// </summary>
        /// <param model="model"></param>
        /// <param IfcBuilding="_building"></param>
        /// <returns></returns>
        private IfcBuilding CopyBuilding(XbimModel model, IfcBuilding _building)
        {
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Building"))
            {
                var building = model.Instances.New<IfcBuilding>();
                building.GlobalId = _building.GlobalId;
                building.Name = _building.Name;
                building.OwnerHistory.OwningUser = model.DefaultOwningUser;
                building.OwnerHistory.OwningApplication = model.DefaultOwningApplication;
                //building.ElevationOfRefHeight = elevHeight;
                building.CompositionType = _building.CompositionType; //IfcElementCompositionEnum.ELEMENT;
                building.ObjectPlacement = model.Instances.New<IfcLocalPlacement>();

                var  localPlacement =  building.ObjectPlacement as IfcLocalPlacement;
                var _localPlacement = _building.ObjectPlacement as IfcLocalPlacement;

                if (localPlacement != null && localPlacement.RelativePlacement == null)
                {

                    localPlacement.RelativePlacement = model.Instances.New<IfcAxis2Placement3D>();
                    //IfcAxis2Placement axis = _localPlacement.RelativePlacement;
                    var  placement = localPlacement.RelativePlacement as IfcAxis2Placement3D;
                    var _placement = _localPlacement.RelativePlacement as IfcAxis2Placement3D;
                    //placement.Axis = _placement.Axis;
                    //placement.Location = _placement.Location;
                    //placement.RefDirection = _placement.RefDirection;
                    placement.SetNewLocation(_placement.Location.X, _placement.Location.Y, _placement.Location.Z);
                }

                model.IfcProject.AddBuilding(building);
                //validate and commit changes
                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return building;
                }

            }
            return null;
        }
Exemplo n.º 6
0
        private IfcBuildingStorey CopyBuildingStorey(XbimModel model, IfcBuildingStorey _buildingStory, IfcBuilding _building)
        {
            using (XbimReadWriteTransaction txn = model.BeginTransaction("Create Building Story"))
            {
                var buildingStory = model.Instances.New<IfcBuildingStorey>();
                buildingStory.GlobalId = _buildingStory.GlobalId;
                buildingStory.Name = _buildingStory.Name;
                buildingStory.OwnerHistory.OwningUser = model.DefaultOwningUser;
                buildingStory.OwnerHistory.OwningApplication = model.DefaultOwningApplication;
                buildingStory.CompositionType = _buildingStory.CompositionType;
                buildingStory.ObjectPlacement = model.Instances.New<IfcLocalPlacement>();

                var localPlacement = buildingStory.ObjectPlacement as IfcLocalPlacement;
                var _localPlacement = _buildingStory.ObjectPlacement as IfcLocalPlacement;

                if (localPlacement != null && localPlacement.RelativePlacement == null)
                {

                    localPlacement.RelativePlacement = model.Instances.New<IfcAxis2Placement3D>();
                    //IfcAxis2Placement axis = _localPlacement.RelativePlacement;
                    var placement = localPlacement.RelativePlacement as IfcAxis2Placement3D;
                    var _placement = _localPlacement.RelativePlacement as IfcAxis2Placement3D;
                    //placement.Axis = _placement.Axis;
                    //placement.Location = _placement.Location;
                    //placement.RefDirection = _placement.RefDirection;
                    placement.SetNewLocation(_placement.Location.X, _placement.Location.Y, _placement.Location.Z);
                }

                var ifcRel = model.Instances.New<IfcRelAggregates>();
                ifcRel.RelatingObject = _building;//.RelatingMaterial = material;
                ifcRel.RelatedObjects.Add(buildingStory);
                //_building.AddElement(buildingStory);

                if (model.Validate(txn.Modified(), Console.Out) == 0)
                {
                    txn.Commit();
                    return buildingStory;
                }

            }
            return null;
        }
 internal XbimBuildingCommonProperties(IfcBuilding building) : base(building, "Pset_BuildingCommon") { }
Exemplo n.º 8
0
        /// <summary>
        /// Set the area measure to the building
        /// </summary>
        /// <param name="ifcBuilding">Building object</param>
        /// <param name="row">COBieFacilityRow object holding data</param>
        private void SetAreaMeasure(IfcBuilding ifcBuilding, COBieFacilityRow row)
        {
            IfcSIUnit ifcSIUnitArea = null;
           if (ValidateString(row.AreaUnits))
            {
                ifcSIUnitArea = GetSIUnit(row.AreaUnits);
            }
           string areaMeasure = string.Empty;
           if (ValidateString(row.AreaMeasurement))
           {
               areaMeasure = row.AreaMeasurement;
           }
            
           IfcQuantityArea IfcQuantityArea = Model.Instances.New<IfcQuantityArea>(qa => 
                                                { 
                                                    qa.Unit = ifcSIUnitArea;
                                                    qa.Name = "AreaMeasure";
                                                    qa.Description = "Created to maintain COBie information";
                                               });
           IfcElementQuantity ifcElementQuantity = Model.Instances.New<IfcElementQuantity>(eq =>
                                                        {
                                                            eq.Quantities.Add(IfcQuantityArea);
                                                            eq.MethodOfMeasurement = areaMeasure;
                                                            eq.Description = "Created to maintain COBie information";
 
                                                        });
           IfcRelDefinesByProperties ifcRelDefinesByProperties = Model.Instances.New<IfcRelDefinesByProperties>(rdbp =>
                                                               {
                                                                   rdbp.RelatedObjects.Add(ifcBuilding);
                                                                   rdbp.RelatingPropertyDefinition = ifcElementQuantity;
                                                                   rdbp.Description = "Created to maintain COBie information";
                                                               });
        }
Exemplo n.º 9
0
 internal XbimBuildingQuantities(IfcBuilding building) : base(building, "BuildingQuantities") { }
Exemplo n.º 10
0
 //internal constructor for creation from XbimDocument (parsing data into the document)
 internal XbimBuilding(XbimDocument document, IfcBuilding building): base(document, building) { }
Exemplo n.º 11
0
        public FacilityType(IfcBuilding ifcBuilding, CoBieLiteHelper helper)
            : this()
        {
            //   _ifcBuilding = ifcBuilding;
            var model = ifcBuilding.ModelOf;
            externalEntityName = helper.ExternalEntityName(ifcBuilding);
            externalID = helper.ExternalEntityIdentity(ifcBuilding);
            externalSystemName = helper.ExternalSystemName(ifcBuilding);
            FacilityName = ifcBuilding.Name;
            FacilityDescription = ifcBuilding.Description;
            FacilityCategory = helper.GetClassification(ifcBuilding);
            var ifcProject = model.Instances.OfType<IfcProject>().FirstOrDefault();
            if (ifcProject != null)
            {
                ProjectAssignment = new ProjectType(ifcProject, helper);
                var ifcSite = ifcProject.GetSpatialStructuralElements().FirstOrDefault(p => p is IfcSite) as IfcSite;
                if (ifcSite != null) SiteAssignment = new SiteType(ifcSite, helper);
                SetDefaultUnits(helper);
                FacilityDeliverablePhaseName = ifcProject.Phase;
                var storeys = ifcBuilding.GetBuildingStoreys(true);
                var ifcBuildingStories = storeys as IList<IfcBuildingStorey> ?? storeys.ToList();
                if (ifcBuildingStories.Any())
                {
                    Floors = new FloorCollectionType {Floor = new List<FloorType>(ifcBuildingStories.Count)};
                    for (int i = 0; i < ifcBuildingStories.Count; i++)
                    {
                        Floors.Add(new FloorType(ifcBuildingStories[i], helper));
                    }
                }
            }
            //Attributes
            var ifcAttributes = helper.GetAttributes(ifcBuilding);
            if (ifcAttributes != null && ifcAttributes.Any())
                FacilityAttributes = new AttributeCollectionType {Attribute = ifcAttributes};

            //Zones

            var allSpaces = GetAllSpaces(ifcBuilding);
            var allZones = GetAllZones(allSpaces, helper);
            var ifcZones = allZones.ToArray();
            if (ifcZones.Any())
            {
                Zones = new ZoneCollectionType {Zone = new List<ZoneType>(ifcZones.Length)};
                for (int i = 0; i < ifcZones.Length; i++)
                {
                    Zones.Add(new ZoneType(ifcZones[i], helper));
                }
            }

            //Assets
            var allAssetsinThisFacility = new HashSet<IfcElement>(helper.GetAllAssets(ifcBuilding));

            //AssetTypes
            //Get all assets that are in this facility/building
            var allAssetTypesInThisFacility = AllAssetTypesInThisFacility(ifcBuilding, allAssetsinThisFacility, helper);
            if (allAssetTypesInThisFacility.Any())
            {
                AssetTypes = new AssetTypeCollectionType
                {
                    AssetType = new List<AssetTypeInfoType>(allAssetTypesInThisFacility.Count)
                };
                for (int i = 0; i < allAssetTypesInThisFacility.Count; i++)
                {
                    AssetTypes.Add(new AssetTypeInfoType(allAssetTypesInThisFacility[i], helper));
                }
            }

            //Systems
            var allSystemsInThisFacility = helper.SystemAssignment
                .Where(v => v.Value.Any(allAssetsinThisFacility.Contains))
                .Select(k => k.Key).ToArray();
            if (allSystemsInThisFacility.Any())
            {
                Systems = new SystemCollectionType
                {
                    System = new List<SystemType>(allSystemsInThisFacility.Length)
                };

                for (int i = 0; i < allSystemsInThisFacility.Length; i++)
                {
                    Systems.Add(new SystemType(allSystemsInThisFacility[i], helper));
                }
            }

            //Contacts
            var contacts = helper.GetContacts();
            var ifcActors = contacts as IfcActorSelect[] ?? contacts.ToArray();
            if (ifcActors.Any())
            {
                Contacts = new ContactCollectionType
                {
                    Contact = new List<ContactType>(ifcActors.Length)
                };

                for (int i = 0; i < ifcActors.Length; i++)
                {
                    Contacts.Add(new ContactType(ifcActors[i], helper));
                }
            }

        }
Exemplo n.º 12
0
 private IEnumerable<IfcSpace> GetAllSpaces(IfcBuilding ifcBuilding)
 {
     var spaces = new HashSet<IfcSpace>();
     foreach (var space in ifcBuilding.GetSpaces().ToList())
         spaces.Add(space);
     foreach (var storey in ifcBuilding.GetBuildingStoreys().ToList())
     {
         foreach (var storeySpace in storey.GetSpaces().ToList())
         {
             spaces.Add(storeySpace);
             foreach (var spaceSpace in storeySpace.GetSpaces().ToList())
                 spaces.Add(spaceSpace); //get sub spaces
         }
     }
     return spaces;
 }
Exemplo n.º 13
0
        private static List<IfcTypeObject> AllAssetTypesInThisFacility(IfcBuilding ifcBuilding,
            HashSet<IfcElement> allAssetsinThisFacility, CoBieLiteHelper helper)
        {

            var allAssetTypes = helper.DefiningTypeObjectMap;
            var allAssetTypesInThisFacility = new List<IfcTypeObject>(allAssetTypes.Count);
            foreach (var assetTypeKeyValue in allAssetTypes)
            {
                //if any defining type has an object in this building/facility then we need to include it
                if (assetTypeKeyValue.Value.Any(allAssetsinThisFacility.Contains))
                    allAssetTypesInThisFacility.Add(assetTypeKeyValue.Key);
            }
            return allAssetTypesInThisFacility;
        }