Пример #1
0
        /// <summary>
        /// XBim Serialise
        /// </summary>
        /// <param name="workbook">COBieWorkbook to Serialise</param>
        public void Create(COBieWorkbook workbook)
        {
            
            XBimContext.Reset(); //clear out the dictionaries
            XBimContext.WorkBook = workbook;
            ModelSetUp();

            COBieXBimContact xBimContact = new COBieXBimContact(XBimContext);
            xBimContact.SerialiseContacts((COBieSheet<COBieContactRow>)WorkBook[Constants.WORKSHEET_CONTACT]);

            COBieXBimFacility xBimFacility = new COBieXBimFacility(XBimContext);
            xBimFacility.SerialiseFacility((COBieSheet<COBieFacilityRow>)WorkBook[Constants.WORKSHEET_FACILITY]);

            COBieXBimFloor xBimFloor = new COBieXBimFloor(XBimContext);
            xBimFloor.SerialiseFloor((COBieSheet<COBieFloorRow>)WorkBook[Constants.WORKSHEET_FLOOR]);
            
            COBieXBimSpace xBimSpace = new COBieXBimSpace(XBimContext);
            xBimSpace.SerialiseSpace((COBieSheet<COBieSpaceRow>)WorkBook[Constants.WORKSHEET_SPACE]);

            COBieXBimZone xBimZone = new COBieXBimZone(XBimContext);
            xBimZone.SerialiseZone((COBieSheet<COBieZoneRow>)WorkBook[Constants.WORKSHEET_ZONE]);

            COBieXBimType xBimType = new COBieXBimType(XBimContext);
            xBimType.SerialiseType((COBieSheet<COBieTypeRow>)WorkBook[Constants.WORKSHEET_TYPE]);

            COBieXBimComponent xBimComponent = new COBieXBimComponent(XBimContext);
            xBimComponent.SerialiseComponent((COBieSheet<COBieComponentRow>)WorkBook[Constants.WORKSHEET_COMPONENT]);

            COBieXBimSystem xBimSystem = new COBieXBimSystem(XBimContext);
            xBimSystem.SerialiseSystem((COBieSheet<COBieSystemRow>)WorkBook[Constants.WORKSHEET_SYSTEM]);

            COBieXBimAssembly xBimAssembly = new COBieXBimAssembly(XBimContext);
            xBimAssembly.SerialiseAssembly((COBieSheet<COBieAssemblyRow>)WorkBook[Constants.WORKSHEET_ASSEMBLY]);

            COBieXBimConnection xBimConnection = new COBieXBimConnection(XBimContext);
            xBimConnection.SerialiseConnection((COBieSheet<COBieConnectionRow>)WorkBook[Constants.WORKSHEET_CONNECTION]);
            
            COBieXBimSpare xBimSpare = new COBieXBimSpare(XBimContext);
            xBimSpare.SerialiseSpare((COBieSheet<COBieSpareRow>)WorkBook[Constants.WORKSHEET_SPARE]);

            COBieXBimResource xBimResource = new COBieXBimResource(XBimContext);
            xBimResource.SerialiseResource((COBieSheet<COBieResourceRow>)WorkBook[Constants.WORKSHEET_RESOURCE]);

            COBieXBimJob xBimJob = new COBieXBimJob(XBimContext);
            xBimJob.SerialiseJob((COBieSheet<COBieJobRow>)WorkBook[Constants.WORKSHEET_JOB]);

            COBieXBimImpact xBimImpact = new COBieXBimImpact(XBimContext);
            xBimImpact.SerialiseImpact((COBieSheet<COBieImpactRow>)WorkBook[Constants.WORKSHEET_IMPACT]);

            COBieXBimDocument xBimDocument = new COBieXBimDocument(XBimContext);
            xBimDocument.SerialiseDocument((COBieSheet<COBieDocumentRow>)WorkBook[Constants.WORKSHEET_DOCUMENT]);

            COBieXBimAttribute xBimAttribute = new COBieXBimAttribute(XBimContext);
            xBimAttribute.SerialiseAttribute((COBieSheet<COBieAttributeRow>)WorkBook[Constants.WORKSHEET_ATTRIBUTE]);
            
            COBieXBimCoordinate xBimCoordinate = new COBieXBimCoordinate(XBimContext);
            xBimCoordinate.SerialiseCoordinate((COBieSheet<COBieCoordinateRow>)WorkBook[Constants.WORKSHEET_COORDINATE]);
            
            COBieXBimIssue xBimIssue = new COBieXBimIssue(XBimContext);
            xBimIssue.SerialiseIssue((COBieSheet<COBieIssueRow>)WorkBook[Constants.WORKSHEET_ISSUE]);
            
            
        }
Пример #2
0
        /// <summary>
        /// XBim Merge
        /// </summary>
        /// <param name="workbook">COBieWorkbook to Serialise</param>
        public void Merge(COBieWorkbook workbook)
        {
            XBimContext.IsMerge = true; //flag as a merge
            XBimContext.WorkBook = workbook;

            if (!MergeGeometryOnly)
            {
                COBieXBimContact xBimContact = new COBieXBimContact(XBimContext);
                xBimContact.SerialiseContacts((COBieSheet<COBieContactRow>)WorkBook[Constants.WORKSHEET_CONTACT]);
            }
            
            //Make the assumption we are merging on the same building
            //COBieXBimFacility xBimFacility = new COBieXBimFacility(XBimContext);
            //xBimFacility.SerialiseFacility((COBieSheet<COBieFacilityRow>)WorkBook[Constants.WORKSHEET_FACILITY]);

            COBieXBimFloor xBimFloor = new COBieXBimFloor(XBimContext);
            xBimFloor.SerialiseFloor((COBieSheet<COBieFloorRow>)WorkBook[Constants.WORKSHEET_FLOOR]);

            COBieXBimSpace xBimSpace = new COBieXBimSpace(XBimContext);
            xBimSpace.SerialiseSpace((COBieSheet<COBieSpaceRow>)WorkBook[Constants.WORKSHEET_SPACE]);

            if (!MergeGeometryOnly)
            {
                COBieXBimZone xBimZone = new COBieXBimZone(XBimContext);
                xBimZone.SerialiseZone((COBieSheet<COBieZoneRow>)WorkBook[Constants.WORKSHEET_ZONE]);
            } 
            COBieXBimType xBimType = new COBieXBimType(XBimContext);
            xBimType.SerialiseType((COBieSheet<COBieTypeRow>)WorkBook[Constants.WORKSHEET_TYPE]);

            COBieXBimComponent xBimComponent = new COBieXBimComponent(XBimContext);
            xBimComponent.SerialiseComponent((COBieSheet<COBieComponentRow>)WorkBook[Constants.WORKSHEET_COMPONENT]);

            if (!MergeGeometryOnly)
            {
                COBieXBimSystem xBimSystem = new COBieXBimSystem(XBimContext);
                xBimSystem.SerialiseSystem((COBieSheet<COBieSystemRow>)WorkBook[Constants.WORKSHEET_SYSTEM]);

                COBieXBimAssembly xBimAssembly = new COBieXBimAssembly(XBimContext);
                xBimAssembly.SerialiseAssembly((COBieSheet<COBieAssemblyRow>)WorkBook[Constants.WORKSHEET_ASSEMBLY]);

                COBieXBimConnection xBimConnection = new COBieXBimConnection(XBimContext);
                xBimConnection.SerialiseConnection((COBieSheet<COBieConnectionRow>)WorkBook[Constants.WORKSHEET_CONNECTION]);

                COBieXBimSpare xBimSpare = new COBieXBimSpare(XBimContext);
                xBimSpare.SerialiseSpare((COBieSheet<COBieSpareRow>)WorkBook[Constants.WORKSHEET_SPARE]);

                COBieXBimResource xBimResource = new COBieXBimResource(XBimContext);
                xBimResource.SerialiseResource((COBieSheet<COBieResourceRow>)WorkBook[Constants.WORKSHEET_RESOURCE]);

                COBieXBimJob xBimJob = new COBieXBimJob(XBimContext);
                xBimJob.SerialiseJob((COBieSheet<COBieJobRow>)WorkBook[Constants.WORKSHEET_JOB]);

                COBieXBimImpact xBimImpact = new COBieXBimImpact(XBimContext);
                xBimImpact.SerialiseImpact((COBieSheet<COBieImpactRow>)WorkBook[Constants.WORKSHEET_IMPACT]);

                COBieXBimDocument xBimDocument = new COBieXBimDocument(XBimContext);
                xBimDocument.SerialiseDocument((COBieSheet<COBieDocumentRow>)WorkBook[Constants.WORKSHEET_DOCUMENT]);

                COBieXBimAttribute xBimAttribute = new COBieXBimAttribute(XBimContext);
                xBimAttribute.SerialiseAttribute((COBieSheet<COBieAttributeRow>)WorkBook[Constants.WORKSHEET_ATTRIBUTE]);
            }

            COBieXBimCoordinate xBimCoordinate = new COBieXBimCoordinate(XBimContext);
            xBimCoordinate.SerialiseCoordinate((COBieSheet<COBieCoordinateRow>)WorkBook[Constants.WORKSHEET_COORDINATE]);
            if (!MergeGeometryOnly)
            {
                COBieXBimIssue xBimIssue = new COBieXBimIssue(XBimContext);
                xBimIssue.SerialiseIssue((COBieSheet<COBieIssueRow>)WorkBook[Constants.WORKSHEET_ISSUE]);
            }
            
        }
Пример #3
0
        /// <summary>
        /// Add the object the document relates too
        /// </summary>
        /// <param name="row">COBieDocumentRow holding row data</param>
        private IfcRoot GetObjectRelationship(COBieDocumentRow row)
        {
            IfcRoot ifcRoot = null;

            if ((ValidateString(row.SheetName)) && (ValidateString(row.RowName)))
            {
                string sheetName = row.SheetName.ToLower().Trim();
                sheetName = char.ToUpper(sheetName[0]) + sheetName.Substring(1);

                string rowName = row.RowName.ToLower().Trim();

                string extObject = string.Empty;
                if (ValidateString(row.ExtObject)) //if valid change to correct type
                {
                    extObject = row.ExtObject.Trim().ToUpper();
                }

                switch (sheetName)
                {
                case Constants.WORKSHEET_TYPE:
                    //get all types, one time only
                    if (IfcTypeObjects == null)
                    {
                        IfcTypeObjects = Model.FederatedInstances.OfType <IfcTypeObject>();
                    }
                    ifcRoot = IfcTypeObjects.Where(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    if (ifcRoot == null)
                    {
                        string typeName = string.Empty;
                        if (ValidateString(extObject))
                        {
                            typeName = extObject;
                        }
                        else
                        {
                            typeName = "IFCBUILDINGELEMENTPROXYTYPE";
                        }
                        ifcRoot             = COBieXBimType.GetTypeInstance(typeName, Model);
                        ifcRoot.Name        = row.RowName;
                        ifcRoot.Description = "Created to maintain relationship with document object from COBie information";
                    }
                    break;

                case Constants.WORKSHEET_COMPONENT:
                    //get all types, one time only
                    if (IfcElements == null)
                    {
                        IfcElements = Model.FederatedInstances.OfType <IfcElement>();
                    }
                    ifcRoot = IfcElements.Where(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    string elementTypeName = "IFCVIRTUALELEMENT";
                    if (ifcRoot == null)
                    {
                        if (ValidateString(extObject))     //if valid change to correct type
                        {
                            elementTypeName = extObject;
                        }

                        ifcRoot             = COBieXBimComponent.GetElementInstance(elementTypeName, Model);
                        ifcRoot.Name        = row.RowName;
                        ifcRoot.Description = "Created to maintain relationship with document object from COBie information";
                    }
                    else if ((ifcRoot.GetType().Name.ToUpper() == elementTypeName) && //check type, if IFCVIRTUALELEMENT and
                             (ValidateString(extObject)) &&
                             (extObject != elementTypeName) &&                        //not IFCVIRTUALELEMENT then delete virtual, and add correct type
                             (ValidateString(ifcRoot.Description)) &&                 //ensure we set to maintain relationship on another sheet
                             (ifcRoot.Description.ToString().Contains("COBie information"))
                             )
                    {
                        try
                        {
                            Model.Delete(ifcRoot);     //remove IFCVIRTUALELEMENT, probably added by system sheet
                            elementTypeName     = extObject;
                            ifcRoot             = COBieXBimComponent.GetElementInstance(elementTypeName, Model);
                            ifcRoot.Name        = row.RowName;
                            ifcRoot.Description = "Created to maintain relationship with document object from COBie information";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(string.Format("Failed to delete ifcRelDecomposes in AddObjectRelationship() - {0}", ex.Message));
                        }
                    }
                    break;

                case Constants.WORKSHEET_JOB:
                    ifcRoot = Model.FederatedInstances.Where <IfcProcess>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_ASSEMBLY:
                    ifcRoot = Model.FederatedInstances.Where <IfcRelDecomposes>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_CONNECTION:
                    ifcRoot = Model.FederatedInstances.Where <IfcRelConnects>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_FACILITY:
                    ifcRoot = Model.FederatedInstances.Where <IfcBuilding>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    if (ifcRoot == null)
                    {
                        ifcRoot = Model.FederatedInstances.Where <IfcSite>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    }
                    if (ifcRoot == null)
                    {
                        ifcRoot = Model.FederatedInstances.Where <IfcProject>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    }
                    break;

                case Constants.WORKSHEET_FLOOR:
                    ifcRoot = Model.FederatedInstances.Where <IfcBuildingStorey>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_RESOURCE:
                    ifcRoot = Model.FederatedInstances.Where <IfcConstructionEquipmentResource>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_SPACE:
                    ifcRoot = Model.FederatedInstances.Where <IfcSpace>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_SPARE:
                    ifcRoot = Model.FederatedInstances.Where <IfcConstructionProductResource>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_SYSTEM:
                    ifcRoot = Model.FederatedInstances.Where <IfcGroup>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                case Constants.WORKSHEET_ZONE:
                    ifcRoot = Model.FederatedInstances.Where <IfcZone>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                    break;

                //case "document": //not derived from IfcRoot
                //    ifcRoot = Model.FederatedInstances.Where<IfcDocumentInformation>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                //    break;
                //case "contact": //not derived from IfcRoot
                //    ifcRoot = Model.FederatedInstances.Where<IfcPersonAndOrganization>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                //    break;
                //case "issue": //not derived from IfcRoot
                //    ifcRoot = Model.FederatedInstances.Where<IfcApproval>(to => to.Name.ToString().ToLower().Trim() == rowName).FirstOrDefault();
                //    break;
                default:
                    break;
                }
            }
            return(ifcRoot);
        }