/// <summary> /// Create and setup objects held in the Floor COBieSheet /// </summary> /// <param name="cOBieSheet">COBieSheet of COBieFloorRows to read data from</param> public void SerialiseFloor(COBieSheet <COBieFloorRow> cOBieSheet) { using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Floor")) { try { int count = 1; ProgressIndicator.ReportMessage("Starting Floors..."); ProgressIndicator.Initialise("Creating Floors", cOBieSheet.RowCount); for (int i = 0; i < cOBieSheet.RowCount; i++) { BumpTransaction(trans, count); count++; ProgressIndicator.IncrementAndUpdate(); COBieFloorRow row = cOBieSheet[i]; AddBuildingStory(row); } ProgressIndicator.Finalise(); trans.Commit(); } catch (Exception) { //TODO: Catch with logger? throw; } } }
/// <summary> /// Add the data to the BuildingStory object /// </summary> /// <param name="row">COBieFloorRow holding the data</param> private void AddBuildingStory(COBieFloorRow row) { //we are merging so check for an existing item name, assume the same item as should be the same building, maybe should do a check on that if (CheckIfExistOnMerge <IfcBuildingStorey>(row.Name)) { return;//we have it so no need to create } IfcBuildingStorey ifcBuildingStorey = Model.Instances.New <IfcBuildingStorey>(); //Set the CompositionType to Element as it is a required field ifcBuildingStorey.CompositionType = IfcElementCompositionEnum.ELEMENT; //Add Created By, Created On and ExtSystem to Owner History. SetUserHistory(ifcBuildingStorey, row.ExtSystem, row.CreatedBy, row.CreatedOn); //using statement will set the Model.OwnerHistoryAddObject to ifcBuildingStorey.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)) { //Add Name if (ValidateString(row.Name)) { ifcBuildingStorey.Name = row.Name; } //Add Category AddCategory(row.Category, ifcBuildingStorey); //Add GlobalId AddGlobalId(row.ExtIdentifier, ifcBuildingStorey); //Add Elevation if (ValidateString(row.Elevation)) { ifcBuildingStorey.Elevation = GetDoubleFromString(row.Elevation); } //Add Floor Height AddFloorHeight(row.Height, ifcBuildingStorey); //add Description if (ValidateString(row.Description)) { ifcBuildingStorey.Description = row.Description; } //create relationship between building and building story GetBuilding().AddToSpatialDecomposition(ifcBuildingStorey); } }