/// <summary> /// Add floor placement point /// </summary> /// <param name="row">COBieCoordinateRow holding the data</param> private void AddFloorPlacement(COBieCoordinateRow row) { IfcBuildingStorey ifcBuildingStorey = null; if (ValidateString(row.ExtIdentifier)) { IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier); ifcBuildingStorey = Model.FederatedInstances.Where <IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault(); } if ((ifcBuildingStorey == null) && (ValidateString(row.RowName))) { ifcBuildingStorey = Model.FederatedInstances.Where <IfcBuildingStorey>(bs => bs.Name == row.RowName).FirstOrDefault(); } if (ifcBuildingStorey != null) { var placementRelToIfcProduct = ifcBuildingStorey.GetContainingStructuralElement(); IfcLocalPlacement objectPlacement = CalcObjectPlacement(row, placementRelToIfcProduct); if (objectPlacement != null) { //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcBuildingStorey.OwnerHistory)) { ifcBuildingStorey.ObjectPlacement = objectPlacement; } } } }
/// <summary> /// Add space placement /// </summary> /// <param name="row">COBieCoordinateRow holding the data for one corner</param> /// <param name="rowNext">COBieCoordinateRow holding the data for the other corner</param> private void AddBoundingBoxAsExtrudedAreaSolid(COBieCoordinateRow row, COBieCoordinateRow rowNext) { if (row.SheetName.ToLower() == "floor") { IfcBuildingStorey ifcBuildingStorey = null; if (ValidateString(row.ExtIdentifier)) { IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier); ifcBuildingStorey = Model.FederatedInstances.Where <IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault(); } if ((ifcBuildingStorey == null) && (ValidateString(row.RowName))) { ifcBuildingStorey = Model.FederatedInstances.Where <IfcBuildingStorey>(bs => bs.Name == row.RowName).FirstOrDefault(); } if (ifcBuildingStorey != null) { //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcBuildingStorey.OwnerHistory)) { var placementRelToIfcProduct = ifcBuildingStorey.GetContainingStructuralElement(); AddExtrudedRectangle(row, rowNext, ifcBuildingStorey, placementRelToIfcProduct); } } } if (row.SheetName.ToLower() == "space") { IfcSpace ifcSpace = null; if (ValidateString(row.ExtIdentifier)) { IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier); ifcSpace = Model.FederatedInstances.Where <IfcSpace>(bs => bs.GlobalId == id).FirstOrDefault(); } if ((ifcSpace == null) && (ValidateString(row.RowName))) { ifcSpace = Model.FederatedInstances.Where <IfcSpace>(bs => bs.Name == row.RowName).FirstOrDefault(); } if ((ifcSpace == null) && (ValidateString(row.RowName))) { IEnumerable <IfcSpace> ifcSpaces = Model.FederatedInstances.Where <IfcSpace>(bs => bs.Description == row.RowName); //check we have one, if >1 then no match if ((ifcSpaces.Any()) && (ifcSpaces.Count() == 1)) { ifcSpace = ifcSpaces.FirstOrDefault(); } } if (ifcSpace != null) { if (ifcSpace.Representation != null) //check it has no graphics attached, if it has then skip { return; } //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcSpace.OwnerHistory)) { var placementRelToIfcProduct = ifcSpace.GetContainingStructuralElement(); AddExtrudedRectangle(row, rowNext, ifcSpace, placementRelToIfcProduct); } } } if (row.SheetName.ToLower() == "component") { IfcElement ifcElement = null; if (ValidateString(row.ExtIdentifier)) { IfcGloballyUniqueId id = new IfcGloballyUniqueId(row.ExtIdentifier); ifcElement = Model.FederatedInstances.Where <IfcElement>(bs => bs.GlobalId == id).FirstOrDefault(); } if ((ifcElement == null) && (ValidateString(row.RowName))) { ifcElement = Model.FederatedInstances.Where <IfcElement>(bs => bs.Name == row.RowName).FirstOrDefault(); } if ((ifcElement == null) && (ValidateString(row.RowName))) { IEnumerable <IfcElement> ifcElements = Model.FederatedInstances.Where <IfcElement>(bs => bs.Description == row.RowName); //check we have one, if >1 then no match if ((ifcElements.Any()) && (ifcElements.Count() == 1)) { ifcElement = ifcElements.FirstOrDefault(); } } if (ifcElement != null) { if (ifcElement.Representation != null) //check it has no graphics attached, if it has then skip { return; } //using statement will set the Model.OwnerHistoryAddObject to IfcRoot.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcElement.OwnerHistory)) { IfcProduct placementRelToIfcProduct = ifcElement.ContainedInStructure as IfcProduct; IfcRelContainedInSpatialStructure ifcRelContainedInSpatialStructure = Model.FederatedInstances.OfType <IfcRelContainedInSpatialStructure>().Where(rciss => rciss.RelatedElements.Contains(ifcElement)).FirstOrDefault(); if ((ifcRelContainedInSpatialStructure != null) && (ifcRelContainedInSpatialStructure.RelatingStructure != null) ) { placementRelToIfcProduct = ifcRelContainedInSpatialStructure.RelatingStructure; AddExtrudedRectangle(row, rowNext, ifcElement, placementRelToIfcProduct); } else { #if DEBUG Console.WriteLine("COBieXBimCoordinate.AddBoundingBoxAsExtrudedAreaSolid: Cannot find Parent object placement"); #endif } } } else { #if DEBUG Console.WriteLine("COBieXBimCoordinate.AddBoundingBoxAsExtrudedAreaSolid: Cannot find object to relate points too"); #endif } } }