/// <summary> /// Create and setup objects held in the Space COBieSheet /// </summary> /// <param name="cOBieSheet">COBieSheet of COBieSpaceRows to read data from</param> public void SerialiseSpace(COBieSheet <COBieSpaceRow> cOBieSheet) { using (XbimReadWriteTransaction trans = Model.BeginTransaction("Add Space")) { try { int count = 1; ProgressIndicator.ReportMessage("Starting Spaces..."); ProgressIndicator.Initialise("Creating Spaces", cOBieSheet.RowCount); for (int i = 0; i < cOBieSheet.RowCount; i++) { BumpTransaction(trans, count); count++; ProgressIndicator.IncrementAndUpdate(); COBieSpaceRow row = cOBieSheet[i]; AddSpace(row); } ProgressIndicator.Finalise(); trans.Commit(); } catch (Exception) { //TODO: Catch with logger? throw; } } }
/// <summary> /// Add the data to the Space object /// </summary> /// <param name="row">COBieSpaceRow holding the data</param> private void AddSpace(COBieSpaceRow row) { //we are merging so check for an existing item name, assume the same item as should be the same building if (CheckIfExistOnMerge <IfcSpace>(row.Name)) { return;//we have it so no need to create } IfcSpace ifcSpace = Model.Instances.New <IfcSpace>(); //Set the CompositionType to Element as it is a required field ifcSpace.CompositionType = IfcElementCompositionEnum.ELEMENT; //Add Created By, Created On and ExtSystem to Owner History. SetUserHistory(ifcSpace, row.ExtSystem, row.CreatedBy, row.CreatedOn); //using statement will set the Model.OwnerHistoryAddObject to ifcSpace.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)) { //Add Name if (ValidateString(row.Name)) { ifcSpace.Name = row.Name; } //Add Category AddCategory(row.Category, ifcSpace); //Add Space to the Building Story(Floor) AddSpaceToBuildingStory(row.FloorName, ifcSpace); //Add Description if (ValidateString(row.Description)) { ifcSpace.Description = row.Description; } //Add GlobalId AddGlobalId(row.ExtIdentifier, ifcSpace); //Add Room Tag if (ValidateString(row.RoomTag)) { AddPropertySingleValue(ifcSpace, "Pset_SpaceCommon", "Space Properties From COBie", "RoomTag", "Room Id", new IfcLabel(row.RoomTag)); } //Add Usable Height AddUsableHeight(ifcSpace, row.UsableHeight); //Add gross Floor Area AddGrossArea(ifcSpace, row.GrossArea); //Add Net Floor Area AddNetArea(ifcSpace, row.NetArea); } }