Пример #1
0
        /// <summary>
        /// Create and setup the IfcBuilding building object
        /// </summary>
        /// <param name="row">COBieFacilityRow object to read data from</param>
        private void CreateBuilding(COBieFacilityRow row)
        {
            IfcBuilding ifcBuilding = Model.Instances.New <IfcBuilding>();

            SetNewOwnerHistory(ifcBuilding, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to ifcBuilding.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, ifcBuilding.OwnerHistory))
            {
                AddGlobalId(row.ExternalFacilityIdentifier, ifcBuilding);
                if (ValidateString(row.Name))
                {
                    ifcBuilding.Name = row.Name;
                }
                //add category
                AddCategory(row.Category, ifcBuilding);

                if (ValidateString(row.Description))
                {
                    ifcBuilding.Description = row.Description;
                }
                if (ValidateString(row.AreaMeasurement))
                {
                    SetAreaMeasure(ifcBuilding, row);
                }

                ifcBuilding.CompositionType = IfcElementCompositionEnum.ELEMENT;
                IfcLocalPlacement lp = Model.Instances.New <IfcLocalPlacement>();
                lp.RelativePlacement        = WCS;
                lp.PlacementRelTo           = GetSite().ObjectPlacement;
                ifcBuilding.ObjectPlacement = lp;
            }
        }
        /// <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;
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Add the data to the IfcConstructionEquipmentResource object
        /// </summary>
        /// <param name="row">COBieResourceRow holding the data</param>
        private void AddResource(COBieResourceRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge<IfcConstructionEquipmentResource>(row.Name))
            {
                return;//we have it so no need to create
            }
            IfcConstructionEquipmentResource ifcConstructionEquipmentResource = Model.Instances.New<IfcConstructionEquipmentResource>();
            
            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcConstructionEquipmentResource, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
            //using statement will set the Model.OwnerHistoryAddObject to ifcConstructionEquipmentResource.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, ifcConstructionEquipmentResource.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name)) ifcConstructionEquipmentResource.Name = row.Name;

                //Add Category
                if (ValidateString(row.Category)) ifcConstructionEquipmentResource.ObjectType = row.Category;

                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcConstructionEquipmentResource);

                //add Description
                if (ValidateString(row.Description)) ifcConstructionEquipmentResource.Description = row.Description;
            }
        }
Пример #4
0
        /// <summary>
        /// Create and setup IfcSite object
        /// </summary>
        /// <param name="row">COBieFacilityRow object to read data from</param>
        /// <returns>IfcSite object</returns>
        private void CreateSite(COBieFacilityRow row)
        {
            IfcSite ifcSite = Model.Instances.New <IfcSite>();

            //set owner history
            SetNewOwnerHistory(ifcSite, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn);
            //using statement will set the Model.OwnerHistoryAddObject to ifcSite.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, ifcSite.OwnerHistory))
            {
                AddGlobalId(row.ExternalSiteIdentifier, ifcSite);
                if (ValidateString(row.SiteName))
                {
                    ifcSite.Name = row.SiteName;
                }
                ifcSite.CompositionType = IfcElementCompositionEnum.ELEMENT;
                IfcLocalPlacement lp = Model.Instances.New <IfcLocalPlacement>();
                lp.RelativePlacement    = WCS;
                ifcSite.ObjectPlacement = lp;

                if (ValidateString(row.SiteDescription))
                {
                    ifcSite.Description = row.SiteDescription;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Add system group and fill with data from COBieSystemRow
        /// </summary>
        /// <param name="row">COBieSystemRow holding the data</param>
        private void AddSystem(COBieSystemRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge <IfcSystem>(row.Name))
            {
                string testName = row.Name.ToLower().Trim();
                IfcSystemObj = Model.FederatedInstances.Where <IfcSystem>(bs => bs.Name.ToString().ToLower().Trim() == testName).FirstOrDefault();
                return;//we have it so no need to create
            }

            IfcSystemObj      = GetGroupInstance(row.ExtObject);//Model.Instances.New<IfcSystem>();
            IfcSystemObj.Name = row.Name;

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(IfcSystemObj, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to IfcSystemObj.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, IfcSystemObj.OwnerHistory))
            {
                //Add Category
                AddCategory(row.Category, IfcSystemObj);
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, IfcSystemObj);
                //Add Description
                if (ValidateString(row.Description))
                {
                    IfcSystemObj.Description = row.Description;
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Add the data to the IfcConstructionProductResource object
        /// </summary>
        /// <param name="row">COBieSpareRow holding the data</param>
        private void AddSpare(COBieSpareRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge <IfcConstructionProductResource>(row.Name))
            {
                return;//we have it so no need to create
            }

            IfcConstructionProductResource ifcConstructionProductResource = Model.Instances.New <IfcConstructionProductResource>();

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcConstructionProductResource, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.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, ifcConstructionProductResource.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name))
                {
                    ifcConstructionProductResource.Name = row.Name;
                }

                //Add Category
                AddCategory(row.Category, ifcConstructionProductResource);

                //Add Type Relationship
                if (ValidateString(row.TypeName))
                {
                    List <string> typeNames = SplitString(row.TypeName, ':');
                    IEnumerable <IfcTypeObject> ifcTypeObjects = IfcTypeObjects.Where(to => typeNames.Contains(to.Name.ToString().Trim()));
                    SetRelAssignsToResource(ifcConstructionProductResource, ifcTypeObjects);
                }
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcConstructionProductResource);

                //add Description
                if (ValidateString(row.Description))
                {
                    ifcConstructionProductResource.Description = row.Description;
                }

                if (ValidateString(row.Suppliers))
                {
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", "Spare Properties From COBie", "Suppliers", "Suppliers Contact Details", new IfcLabel(row.Suppliers));
                }

                if (ValidateString(row.SetNumber))
                {
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", null, "SetNumber", "Set Number", new IfcLabel(row.SetNumber));
                }

                if (ValidateString(row.PartNumber))
                {
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", null, "PartNumber", "Part Number", new IfcLabel(row.PartNumber));
                }
            }
        }
Пример #7
0
        /// <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);
            }
        }
Пример #8
0
        /// <summary>
        /// Add the data to the Zone object
        /// </summary>
        /// <param name="row">COBieZoneRow holding the data</param>
        private void AddZone(COBieZoneRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge <IfcZone>(row.Name))
            {
                return;//we have it so no need to create
            }
            IfcZone ifcZone = Model.Instances.New <IfcZone>();

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcZone, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to ifcZone.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, ifcZone.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name))
                {
                    ifcZone.Name = row.Name;
                }

                //Add Category
                AddCategory(row.Category, ifcZone);

                //add space to the zone group
                string spaceNames = row.SpaceNames;
                if (ValidateString(spaceNames))
                {
                    char splitKey = GetSplitChar(spaceNames);
                    //COBieCell spaceCell = row["SpaceNames"];
                    //List<string> spaceArray = new List<string>();
                    //if (spaceCell.COBieColumn.AllowsMultipleValues)
                    //{
                    //    spaceArray = spaceCell.CellValues;
                    //}
                    List <string> spaceArray = SplitString(spaceNames, splitKey); //uses escaped characters
                    foreach (string spaceName in spaceArray)
                    {
                        AddSpaceToZone(spaceName, ifcZone);
                    }
                }


                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcZone);

                //Add Description
                if (ValidateString(row.Description))
                {
                    ifcZone.Description = row.Description;
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Add the data to the Document Information object
        /// </summary>
        /// <param name="row">COBieDocumentRow holding the data</param>
        private void AddDocument(COBieDocumentRow row)
        {
            if (CheckIfExistOnMerge(row)) 
                return; //already in document
            IfcDocumentInformation ifcDocumentInformation = Model.Instances.New<IfcDocumentInformation>();
            IfcRelAssociatesDocument ifcRelAssociatesDocument = Model.Instances.New<IfcRelAssociatesDocument>();
            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcRelAssociatesDocument, row.ExtSystem, row.CreatedBy, row.CreatedOn );
            
            if (Contacts.ContainsKey(row.CreatedBy))
                ifcDocumentInformation.DocumentOwner = Contacts[row.CreatedBy];

            //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.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, ifcRelAssociatesDocument.OwnerHistory))
            {
                //create relationship between Document and ifcObjects it relates too
                ifcRelAssociatesDocument.RelatingDocument = ifcDocumentInformation;
                //Add Name
                if (ValidateString(row.Name)) ifcDocumentInformation.Name = row.Name;

                //Add Category
                if (ValidateString(row.Category)) ifcDocumentInformation.Purpose = row.Category;

                //Add approved By
                if (ValidateString(row.ApprovalBy)) ifcDocumentInformation.IntendedUse = row.ApprovalBy;
                
                //Add Stage
                if (ValidateString(row.Stage)) ifcDocumentInformation.Scope = row.Stage;

                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcRelAssociatesDocument);

                //Add Object Relationship
                IfcRoot ifcRoot = GetObjectRelationship(row);
                //add to the document relationship object
                if (ifcRoot != null)
                    ifcRelAssociatesDocument.RelatedObjects.Add_Reversible(ifcRoot);
                

                //Add Document reference
                AddDocumentReference(row, ifcDocumentInformation);
                
                //add Description
                if (ValidateString(row.Description)) ifcDocumentInformation.Description = row.Description;

                //Add Reference
                if (ValidateString(row.Reference)) 
                    ifcDocumentInformation.DocumentId = row.Reference;
                else
                    ifcDocumentInformation.DocumentId = ""; //required field so add blank string
               
            }
        }
Пример #10
0
        /// <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);
            }
        }
Пример #11
0
        /// <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);
            }
            

        }
Пример #12
0
        /// <summary>
        /// Add the data to the Zone object
        /// </summary>
        /// <param name="row">COBieZoneRow holding the data</param>
        private void AddZone(COBieZoneRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge<IfcZone>(row.Name))
            {
                return;//we have it so no need to create
            }
            IfcZone ifcZone = Model.Instances.New<IfcZone>();
            
            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcZone, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
            //using statement will set the Model.OwnerHistoryAddObject to ifcZone.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, ifcZone.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name)) ifcZone.Name = row.Name;

                //Add Category
                AddCategory(row.Category, ifcZone);

                //add space to the zone group
                string spaceNames = row.SpaceNames;
                if (ValidateString(spaceNames))
                {
                    char splitKey = GetSplitChar(spaceNames);
                    //COBieCell spaceCell = row["SpaceNames"];
                    //List<string> spaceArray = new List<string>();
                    //if (spaceCell.COBieColumn.AllowsMultipleValues)
                    //{
                    //    spaceArray = spaceCell.CellValues;
                    //}
                    List<string> spaceArray = SplitString(spaceNames, splitKey); //uses escaped characters
                    foreach (string spaceName in spaceArray)
                    {
                        AddSpaceToZone(spaceName, ifcZone);
                    }
                }
                

                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcZone);

                //Add Description
                if (ValidateString(row.Description)) ifcZone.Description = row.Description;

            }
        }
Пример #13
0
        /// <summary>
        /// Add the data to the IfcConstructionProductResource object
        /// </summary>
        /// <param name="row">COBieSpareRow holding the data</param>
        private void AddSpare(COBieSpareRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge<IfcConstructionProductResource>(row.Name))
            {
                return;//we have it so no need to create
            }

            IfcConstructionProductResource ifcConstructionProductResource = Model.Instances.New<IfcConstructionProductResource>();
            
            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcConstructionProductResource, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
            //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.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, ifcConstructionProductResource.OwnerHistory)) 
            {
                //Add Name
                if (ValidateString(row.Name)) ifcConstructionProductResource.Name = row.Name;

                //Add Category
                AddCategory(row.Category, ifcConstructionProductResource);

                //Add Type Relationship
                if (ValidateString(row.TypeName))
                {
                    List<string> typeNames = SplitString(row.TypeName, ':');
                    IEnumerable<IfcTypeObject> ifcTypeObjects = IfcTypeObjects.Where(to => typeNames.Contains(to.Name.ToString().Trim()));
                    SetRelAssignsToResource(ifcConstructionProductResource, ifcTypeObjects);
                }
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcConstructionProductResource);

                //add Description
                if (ValidateString(row.Description)) ifcConstructionProductResource.Description = row.Description;

                if (ValidateString(row.Suppliers))
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", "Spare Properties From COBie", "Suppliers", "Suppliers Contact Details", new IfcLabel(row.Suppliers));

                if (ValidateString(row.SetNumber))
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", null, "SetNumber", "Set Number", new IfcLabel(row.SetNumber));

                if (ValidateString(row.PartNumber))
                    AddPropertySingleValue(ifcConstructionProductResource, "Pset_Spare_COBie", null, "PartNumber", "Part Number", new IfcLabel(row.PartNumber));
                
            }
        }
Пример #14
0
        /// <summary>
        /// SetUp the Model Project Object
        /// </summary>
        /// <param name="row">COBieFacilityRow object to read data from</param>
        private void SetUpProject(COBieFacilityRow row)
        {
            IfcProject ifcProject = Model.IfcProject;

            ifcProject.Initialize(ProjectUnits.SIUnitsUK);
            SetOwnerHistory(ifcProject, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn);
            //using statement will set the Model.OwnerHistoryAddObject to ifcProject.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, ifcProject.OwnerHistory))
            {
                if (ValidateString(row.ProjectName))
                {
                    ifcProject.Name = row.ProjectName;
                }

                if (ValidateString(row.ProjectDescription))
                {
                    ifcProject.Description = row.ProjectDescription;
                }
                if (ValidateString(row.Phase))
                {
                    ifcProject.Phase = row.Phase;
                }
                if (ValidateString(row.LinearUnits))
                {
                    SetUnitToProject(IfcUnitEnum.LENGTHUNIT, row.LinearUnits);
                }

                AddGlobalId(row.ExternalProjectIdentifier, ifcProject);


                if (ValidateString(row.AreaUnits))
                {
                    SetUnitToProject(IfcUnitEnum.AREAUNIT, row.AreaUnits);
                }

                if (ValidateString(row.VolumeUnits))
                {
                    SetUnitToProject(IfcUnitEnum.VOLUMEUNIT, row.VolumeUnits);
                }

                if (ValidateString(row.CurrencyUnit))
                {
                    SetMonetaryUnit(row.CurrencyUnit);
                }
            }
        }
Пример #15
0
        /// <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);
            }
            
            
        }
        /// <summary>
        /// Add the data to the IfcConstructionEquipmentResource object
        /// </summary>
        /// <param name="row">COBieResourceRow holding the data</param>
        private void AddResource(COBieResourceRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge <IfcConstructionEquipmentResource>(row.Name))
            {
                return;//we have it so no need to create
            }
            IfcConstructionEquipmentResource ifcConstructionEquipmentResource = Model.Instances.New <IfcConstructionEquipmentResource>();

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcConstructionEquipmentResource, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to ifcConstructionEquipmentResource.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, ifcConstructionEquipmentResource.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name))
                {
                    ifcConstructionEquipmentResource.Name = row.Name;
                }

                //Add Category
                if (ValidateString(row.Category))
                {
                    ifcConstructionEquipmentResource.ObjectType = row.Category;
                }

                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcConstructionEquipmentResource);

                //add Description
                if (ValidateString(row.Description))
                {
                    ifcConstructionEquipmentResource.Description = row.Description;
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Create and setup IfcSite object
        /// </summary>
        /// <param name="row">COBieFacilityRow object to read data from</param>
        /// <returns>IfcSite object</returns>
        private void CreateSite(COBieFacilityRow row)
        {
            IfcSite ifcSite = Model.Instances.New<IfcSite>();
            
            //set owner history
            SetNewOwnerHistory(ifcSite, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn);
            //using statement will set the Model.OwnerHistoryAddObject to ifcSite.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, ifcSite.OwnerHistory))
            {
                AddGlobalId(row.ExternalSiteIdentifier, ifcSite);
                if (ValidateString(row.SiteName))
                    ifcSite.Name = row.SiteName;
                ifcSite.CompositionType = IfcElementCompositionEnum.ELEMENT;
                IfcLocalPlacement lp = Model.Instances.New<IfcLocalPlacement>();
                lp.RelativePlacement = WCS;
                ifcSite.ObjectPlacement = lp;

                if (ValidateString(row.SiteDescription))
                    ifcSite.Description = row.SiteDescription;

            }
        }
Пример #18
0
        /// <summary>
        /// Add system group and fill with data from COBieSystemRow
        /// </summary>
        /// <param name="row">COBieSystemRow holding the data</param>
        private void AddSystem(COBieSystemRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge<IfcSystem>(row.Name))
            {
                string testName = row.Name.ToLower().Trim();
                IfcSystemObj = Model.Instances.Where<IfcSystem>(bs => bs.Name.ToString().ToLower().Trim() == testName).FirstOrDefault();
                return;//we have it so no need to create
            }

            IfcSystemObj = GetGroupInstance(row.ExtObject);//Model.Instances.New<IfcSystem>();
            IfcSystemObj.Name = row.Name;
            
            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(IfcSystemObj, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
            //using statement will set the Model.OwnerHistoryAddObject to IfcSystemObj.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, IfcSystemObj.OwnerHistory))
            {
                //Add Category
                AddCategory(row.Category, IfcSystemObj);
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, IfcSystemObj);
                //Add Description
                if (ValidateString(row.Description)) IfcSystemObj.Description = row.Description;
            }
            
        }
Пример #19
0
        /// <summary>
        /// Add the components and fill with data from COBieComponentRow
        /// </summary>
        /// <param name="row">COBieComponentRow holding the data</param>
        private void AddComponent(COBieComponentRow row)
        {

            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge<IfcElement>(row.Name))
            {
                return;//we have it so no need to create
            }
            //we need the ExtObject to exist to create the object
            //Create object using reflection
            IfcElement ifcElement = GetElementInstance(row.ExtObject, Model);
                    
            if(ifcElement != null)
            {
                //Add Created By, Created On and ExtSystem to Owner History. 
                SetUserHistory(ifcElement, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                //using statement will set the Model.OwnerHistoryAddObject to ifcElement.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))
                {
                    //Add Name
                    string name = row.Name;
                    if (ValidateString(name)) ifcElement.Name = name;

                    //Add description
                    if (ValidateString(row.Description)) ifcElement.Description = row.Description;

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcElement);

                    //Add Property Set Properties
                    if (ValidateString(row.SerialNumber))
                        AddPropertySingleValue(ifcElement, "Pset_Component", "Component Properties From COBie", "SerialNumber", "Serial Number for " + name, new IfcLabel(row.SerialNumber));
                    if (ValidateString(row.InstallationDate))
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "InstallationDate", "Installation Date for " + name, new IfcLabel(row.InstallationDate));
                    if (ValidateString(row.WarrantyStartDate))
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "WarrantyStartDate", "Warranty Start Date for " + name, new IfcLabel(row.WarrantyStartDate));
                    if (ValidateString(row.TagNumber))
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "TagNumber", "Tag Number for " + name, new IfcLabel(row.TagNumber));
                    if (ValidateString(row.BarCode))
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "BarCode", "Bar Code for " + name, new IfcLabel(row.BarCode));
                    if (ValidateString(row.AssetIdentifier))
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "AssetIdentifier", "Asset Identifier for " + name, new IfcLabel(row.AssetIdentifier));
                    //set up relationship of the component to the type the component is
                    if (ValidateString(row.TypeName))
                    {
                        IfcTypeObject ifcTypeObject = IfcTypeObjects.Where(to => to.Name.ToString().ToLower() == row.TypeName.ToLower()).FirstOrDefault();
                        if (ifcTypeObject != null)
                            ifcElement.SetDefiningType(ifcTypeObject, Model);
                        else
                            ifcElement.ObjectType = row.TypeName; //no type so save type name in IfcLable property of IfcObject
                    }
                    //set up relationship of the component to the space
                    if (ValidateString(row.Space))
                    {
                        AddElementRelationship(ifcElement, row.Space);
                    }
                    else
                    {
                        GetBuilding().AddElement(ifcElement); //default to building, probably give incorrect bounding box as we do not know what the element parent was
                    }
                }
            }
            else
            {
#if DEBUG
                Console.WriteLine("Failed to create component {0} of {1}", row.Name, row.ExtObject);
#endif
            }
        }
Пример #20
0
        /// <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.Instances.Where<IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault();
                }

                if ((ifcBuildingStorey == null) && (ValidateString(row.RowName)))
                {
                    ifcBuildingStorey = Model.Instances.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))
                    {
                        IfcProduct placementRelToIfcProduct = ifcBuildingStorey.SpatialStructuralElementParent as IfcProduct;
                        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.Instances.Where<IfcSpace>(bs => bs.GlobalId == id).FirstOrDefault();
                }
                if ((ifcSpace == null) && (ValidateString(row.RowName)))
                {
                    ifcSpace = Model.Instances.Where<IfcSpace>(bs => bs.Name == row.RowName).FirstOrDefault();
                }
                if ((ifcSpace == null) && (ValidateString(row.RowName)))
                {
                    IEnumerable<IfcSpace> ifcSpaces = Model.Instances.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))
                    {
                        IfcProduct placementRelToIfcProduct = ifcSpace.SpatialStructuralElementParent as IfcProduct;

                        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.Instances.Where<IfcElement>(bs => bs.GlobalId == id).FirstOrDefault();
                }
                if ((ifcElement == null) && (ValidateString(row.RowName)))
                {
                    ifcElement = Model.Instances.Where<IfcElement>(bs => bs.Name == row.RowName).FirstOrDefault();
                }

                if ((ifcElement == null) && (ValidateString(row.RowName)))
                {
                    IEnumerable<IfcElement> ifcElements = Model.Instances.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.Instances.OfType<IfcRelContainedInSpatialStructure>().Where(rciss => rciss.RelatedElements.Contains(ifcElement)).FirstOrDefault();
                        if ((ifcRelContainedInSpatialStructure != null) &&
                            (ifcRelContainedInSpatialStructure.RelatingStructure != null)
                            )
                        {
                            placementRelToIfcProduct = ifcRelContainedInSpatialStructure.RelatingStructure as IfcProduct;
                            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
                }
            }
            
        }
Пример #21
0
        /// <summary>
        /// Add an IfcApproval to the model based on COBieIssueRow data
        /// </summary>
        /// <param name="row">COBieIssueRow data</param>
        private void AddIssue(COBieIssueRow row)
        {
            if (CheckIfExistOnMerge(row)) //check on merge to see if IfcApproval exists
            {
                return;                   //already exists
            }
            //create the property set to attach to the approval
            IfcPropertySet ifcPropertySet = Model.Instances.New <IfcPropertySet>();

            ifcPropertySet.Name        = "Pset_Risk";
            ifcPropertySet.Description = "An indication of exposure to mischance, peril, menace, hazard or loss";


            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcPropertySet, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to ifcPropertySet.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, ifcPropertySet.OwnerHistory))
            {
                //create the approval object
                IfcApproval ifcApproval = Model.Instances.New <IfcApproval>();
                //set relationship
                IfcRelAssociatesApproval ifcRelAssociatesApproval = Model.Instances.New <IfcRelAssociatesApproval>();
                ifcRelAssociatesApproval.RelatingApproval = ifcApproval;
                ifcRelAssociatesApproval.RelatedObjects.Add(ifcPropertySet);

                if (ValidateString(row.Name))
                {
                    ifcApproval.Name = row.Name;
                }

                if (ValidateString(row.Type))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Type);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskType", "Identifies the predefined types of risk from which the type required may be set.", ifcValues, _riskTypeEnum, null);
                }

                if (ValidateString(row.Risk))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Risk);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskRating", "Rating of the risk that may be determined from a combination of the risk assessment and risk consequence.", ifcValues, _riskRatingEnum, null);
                }

                if (ValidateString(row.Chance))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Chance);
                    AddPropertyEnumeratedValue(ifcPropertySet, "AssessmentOfRisk", "Likelihood of risk event occurring.", ifcValues, _assessmentOfRiskEnum, null);
                }

                if (ValidateString(row.Impact))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Impact);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskConsequence", "Indicates the level of severity of the consequences that the risk would have in case it happens.", ifcValues, _riskConsequenceEnum, null);
                }

                if (ValidateString(row.SheetName1) && ValidateString(row.RowName1))
                {
                    SetRelObjectToApproval(row.SheetName1, row.RowName1, ifcApproval, ifcRelAssociatesApproval);
                }

                if (ValidateString(row.SheetName2) && ValidateString(row.RowName2))
                {
                    SetRelObjectToApproval(row.SheetName2, row.RowName2, ifcApproval, ifcRelAssociatesApproval);
                }

                if (ValidateString(row.Description))
                {
                    ifcApproval.Description = row.Description;
                }

                if (ValidateString(row.Owner))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Owner);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskOwner", "A determination of who is the owner of the risk by reference to principal roles of organizations within a project.", ifcValues, _riskOwnerEnum, null);
                }

                if (ValidateString(row.Mitigation))
                {
                    AddPropertySingleValue(ifcPropertySet, "PreventiveMeassures", "Identifies preventive measures to be taken to mitigate risk.", new IfcText(row.Mitigation), null);
                }

                //Add Identifier
                if (ValidateString(row.ExtIdentifier))
                {
                    ifcApproval.Identifier = row.ExtIdentifier; // AddGlobalId(row.ExtIdentifier, ifcPropertySet); //IfcApproval gas no GlobalId
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Add products to system group and fill with data from COBieSystemRow
        /// </summary>
        /// <param name="row">COBieSystemRow holding the data</param>
        private void AddProducts(COBieSystemRow row)
        {
            string componentNames = row.ComponentNames;

            using (COBieXBimEditScope context = new COBieXBimEditScope(Model, IfcSystemObj.OwnerHistory))
            {
                List <IfcProduct> ifcProductList = new List <IfcProduct>();

                //check to see is the component name is a single component
                List <string> compNames    = new List <string>();
                string        testCompName = componentNames.ToLower().Trim();
                IfcProduct    ifcProduct   = Model.FederatedInstances.OfType <IfcProduct>().Where(p => p.Name.ToString().ToLower().Trim() == testCompName).FirstOrDefault();
                if (ifcProduct != null)
                {
                    compNames.Add(componentNames);
                }
                else
                {
                    compNames = SplitTheString(componentNames); //multiple components in string
                }
                foreach (string componentName in compNames)
                {
                    ifcProduct = null;
                    if (ValidateString(componentName))
                    {
                        string compName = componentName.ToLower().Trim();
                        ifcProduct = Model.FederatedInstances.OfType <IfcProduct>().Where(p => p.Name.ToString().ToLower().Trim() == compName).FirstOrDefault();
                        if (ifcProduct != null)
                        {
                            ifcProductList.Add(ifcProduct);
                        }
                    }
                    if (ifcProduct == null)
                    {
                        string elementTypeName = GetPrefixType(componentName);
                        if (string.IsNullOrEmpty(elementTypeName))
                        {
                            elementTypeName = "IfcDistributionElement";
                        }
                        ifcProduct = COBieXBimComponent.GetElementInstance(elementTypeName, Model);
                        if (ifcProduct != null)
                        {
                            if (string.IsNullOrEmpty(componentName) || (componentName == Constants.DEFAULT_STRING))
                            {
                                ifcProduct.Name = ""; //row.Name + " " + SystemProdutIndex.ToString();
                                SystemProdutIndex++;
                            }
                            else
                            {
                                ifcProduct.Name = componentName;
                            }
                            ifcProduct.Description = "Created to maintain relationship with System object from COBie information";
                            ifcProductList.Add(ifcProduct);
                        }
                    }
                }
                if (ifcProductList.Count == 0) //no products created so create an IfcDistributionElement as place holder
                {
                    ifcProduct = COBieXBimComponent.GetElementInstance("IfcDistributionElement", Model);
                    if (ifcProduct != null)
                    {
                        ifcProduct.Name        = ""; // row.Name + " " + SystemProdutIndex.ToString(); ;
                        ifcProduct.Description = "Created to maintain relationship with System object from COBie information";
                        ifcProductList.Add(ifcProduct);
                    }
                }

                //if we have found product then add to the IfcSystem group
                foreach (IfcProduct ifcProd in ifcProductList)
                {
                    if (IfcSystemObj.IsGroupedBy != null)                               //if we already have a IfcRelAssignsToGroup assigned to IsGroupedBy
                    {
                        if (!IfcSystemObj.IsGroupedBy.RelatedObjects.Contains(ifcProd)) //check to see if product already exists in group
                        {
                            IfcSystemObj.AddObjectToGroup(ifcProd);                     //if not add
                        }
                    }
                    else
                    {
                        IfcSystemObj.AddObjectToGroup(ifcProd);
                    }
                }
            }
        }
Пример #23
0
        /// <summary>
        /// Add the data to the Document Information object
        /// </summary>
        /// <param name="row">COBieDocumentRow holding the data</param>
        private void AddDocument(COBieDocumentRow row)
        {
            if (CheckIfExistOnMerge(row))
            {
                return; //already in document
            }
            IfcDocumentInformation   ifcDocumentInformation   = Model.Instances.New <IfcDocumentInformation>();
            IfcRelAssociatesDocument ifcRelAssociatesDocument = Model.Instances.New <IfcRelAssociatesDocument>();

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcRelAssociatesDocument, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            if (Contacts.ContainsKey(row.CreatedBy))
            {
                ifcDocumentInformation.DocumentOwner = (IfcPersonAndOrganization)Contacts[row.CreatedBy];
            }

            //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.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, ifcRelAssociatesDocument.OwnerHistory))
            {
                //create relationship between Document and ifcObjects it relates too
                ifcRelAssociatesDocument.RelatingDocument = ifcDocumentInformation;
                //Add Name
                if (ValidateString(row.Name))
                {
                    ifcDocumentInformation.Name = row.Name;
                }

                //Add Category
                if (ValidateString(row.Category))
                {
                    ifcDocumentInformation.Purpose = row.Category;
                }

                //Add approved By
                if (ValidateString(row.ApprovalBy))
                {
                    ifcDocumentInformation.IntendedUse = row.ApprovalBy;
                }

                //Add Stage
                if (ValidateString(row.Stage))
                {
                    ifcDocumentInformation.Scope = row.Stage;
                }

                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcRelAssociatesDocument);

                //Add Object Relationship
                IfcRoot ifcRoot = GetObjectRelationship(row);
                //add to the document relationship object
                if (ifcRoot != null)
                {
                    ifcRelAssociatesDocument.RelatedObjects.Add(ifcRoot);
                }


                //Add Document reference
                AddDocumentReference(row, ifcDocumentInformation);

                //add Description
                if (ValidateString(row.Description))
                {
                    ifcDocumentInformation.Description = row.Description;
                }

                //Add Reference
                if (ValidateString(row.Reference))
                {
                    ifcDocumentInformation.DocumentId = row.Reference;
                }
                else
                {
                    ifcDocumentInformation.DocumentId = ""; //required field so add blank string
                }
            }
        }
        /// <summary>
        /// Add the components and fill with data from COBieComponentRow
        /// </summary>
        /// <param name="row">COBieComponentRow holding the data</param>
        private void AddComponent(COBieComponentRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge <IfcElement>(row.Name))
            {
                return;//we have it so no need to create
            }
            //we need the ExtObject to exist to create the object
            //Create object using reflection
            var ifcElement = GetElementInstance(row.ExtObject, Model);

            if (ifcElement != null)
            {
                //Add Created By, Created On and ExtSystem to Owner History.
                SetUserHistory(ifcElement, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                //using statement will set the Model.OwnerHistoryAddObject to ifcElement.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 (var context = new COBieXBimEditScope(Model, ifcElement.OwnerHistory))
                {
                    //Add Name
                    var name = row.Name;
                    if (ValidateString(name))
                    {
                        ifcElement.Name = name;
                    }

                    //Add description
                    if (ValidateString(row.Description))
                    {
                        ifcElement.Description = row.Description;
                    }

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcElement);

                    //Add Property Set Properties
                    if (ValidateString(row.SerialNumber))
                    {
                        AddPropertySingleValue(ifcElement, "Pset_Component", "Component Properties From COBie", "SerialNumber", "Serial Number for " + name, new IfcLabel(row.SerialNumber));
                    }
                    if (ValidateString(row.InstallationDate))
                    {
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "InstallationDate", "Installation Date for " + name, new IfcLabel(row.InstallationDate));
                    }
                    if (ValidateString(row.WarrantyStartDate))
                    {
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "WarrantyStartDate", "Warranty Start Date for " + name, new IfcLabel(row.WarrantyStartDate));
                    }
                    if (ValidateString(row.TagNumber))
                    {
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "TagNumber", "Tag Number for " + name, new IfcLabel(row.TagNumber));
                    }
                    if (ValidateString(row.BarCode))
                    {
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "BarCode", "Bar Code for " + name, new IfcLabel(row.BarCode));
                    }
                    if (ValidateString(row.AssetIdentifier))
                    {
                        AddPropertySingleValue(ifcElement, "Pset_Component", null, "AssetIdentifier", "Asset Identifier for " + name, new IfcLabel(row.AssetIdentifier));
                    }
                    //set up relationship of the component to the type the component is
                    if (ValidateString(row.TypeName))
                    {
                        var ifcTypeObject = IfcTypeObjects.Where(to => to.Name.ToString().ToLower() == row.TypeName.ToLower()).FirstOrDefault();
                        if (ifcTypeObject != null)
                        {
                            ifcElement.AddDefiningType(ifcTypeObject);
                        }
                        else
                        {
                            ifcElement.ObjectType = row.TypeName; //no type so save type name in IfcLable property of IfcObject
                        }
                    }
                    //set up relationship of the component to the space
                    if (ValidateString(row.Space))
                    {
                        AddElementRelationship(ifcElement, row.Space);
                    }
                    else
                    {
                        GetBuilding().AddElement(ifcElement); //default to building, probably give incorrect bounding box as we do not know what the element parent was
                    }
                }
            }
            else
            {
#if DEBUG
                Console.WriteLine("Failed to create component {0} of {1}", row.Name, row.ExtObject);
#endif
            }
        }
Пример #25
0
        /// <summary>
        /// Add products to system group and fill with data from COBieSystemRow
        /// </summary>
        /// <param name="componentName">COBieSystemRow holding the data</param>
        private void AddProducts(COBieSystemRow row)
        {
            string componentNames = row.ComponentNames;
            using (COBieXBimEditScope context = new COBieXBimEditScope(Model, IfcSystemObj.OwnerHistory))
            {
                
                List<IfcProduct> ifcProductList = new List<IfcProduct>();

                //check to see is the component name is a single component
                List<string> compNames = new List<string>();
                string testCompName = componentNames.ToLower().Trim();
                IfcProduct ifcProduct = Model.Instances.OfType<IfcProduct>().Where(p => p.Name.ToString().ToLower().Trim() == testCompName).FirstOrDefault();
                if (ifcProduct != null)
                    compNames.Add(componentNames);
                else
                    compNames = SplitTheString(componentNames); //multiple components in string

                foreach (string componentName in compNames)
                {
                    ifcProduct = null;
                    if (ValidateString(componentName))
                    {
                        string compName = componentName.ToLower().Trim();
                        ifcProduct = Model.Instances.OfType<IfcProduct>().Where(p => p.Name.ToString().ToLower().Trim() == compName).FirstOrDefault();
                        if (ifcProduct != null)
                            ifcProductList.Add(ifcProduct);
                    }
                    if (ifcProduct == null)
                    {
                        string elementTypeName = GetPrefixType(componentName);
                        if (string.IsNullOrEmpty(elementTypeName))
                        {
                            elementTypeName = "IfcDistributionElement";
                        }
                        ifcProduct = COBieXBimComponent.GetElementInstance(elementTypeName, Model);
                        if (ifcProduct != null)
                        {
                            if (string.IsNullOrEmpty(componentName) || (componentName == Constants.DEFAULT_STRING))
                            {
                                ifcProduct.Name = ""; //row.Name + " " + SystemProdutIndex.ToString();
                                SystemProdutIndex++;
                            }
                            else
                                ifcProduct.Name = componentName;
                            ifcProduct.Description = "Created to maintain relationship with System object from COBie information";
                            ifcProductList.Add(ifcProduct); 
                        }

                    }
                }
                if (ifcProductList.Count == 0) //no products created so create an IfcDistributionElement as place holder
                {
                    ifcProduct = COBieXBimComponent.GetElementInstance("IfcDistributionElement", Model);
                    if (ifcProduct != null)
                    {
                        ifcProduct.Name = ""; // row.Name + " " + SystemProdutIndex.ToString(); ;
                        ifcProduct.Description = "Created to maintain relationship with System object from COBie information";
                        ifcProductList.Add(ifcProduct);
                    }
                }
               
                //if we have found product then add to the IfcSystem group
                foreach (IfcProduct ifcProd in ifcProductList)
                {
                    if (IfcSystemObj.IsGroupedBy != null) //if we already have a IfcRelAssignsToGroup assigned to IsGroupedBy
                    {
                        if (!IfcSystemObj.IsGroupedBy.RelatedObjects.Contains(ifcProd)) //check to see if product already exists in group
                            IfcSystemObj.AddObjectToGroup(ifcProd);//if not add
                    }
                    else
                        IfcSystemObj.AddObjectToGroup(ifcProd);
                }
            }
        }
Пример #26
0
        /// <summary>
        /// Add the Impact and fill with data from COBieComponentRow
        /// </summary>
        /// <param name="row">COBieImpactRow holding the data</param>
        private void AddImpact(COBieImpactRow row)
        {
            string pSetName    = "Pset_EnvironmentalImpactValues";
            string description = Constants.DEFAULT_STRING;

            if (ValidateString(row.Description))
            {
                description = row.Description;
            }

            IfcPropertySet ifcPropertySet = null;

            if (row.SheetName.ToLower().Trim() == "type")
            {
                if (IfcTypeObjects == null)
                {
                    IfcTypeObjects = Model.Instances.OfType <IfcTypeObject>();
                }
                IfcTypeObject ifcTypeObject = IfcTypeObjects.Where(to => to.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                if (ifcTypeObject != null)
                {
                    if (XBimContext.IsMerge)
                    {
                        ifcPropertySet = ifcTypeObject.GetPropertySet(pSetName);
                        if (ifcPropertySet != null) //Property set Pset_EnvironmentalImpactValues already set so assume exists so skip
                        {
#if DEBUG
                            Console.WriteLine("{0} Pset_EnvironmentalImpactValues Property set so skip on merge", ifcTypeObject.GetType().Name);
#endif
                            return;
                        }
                    }

                    ifcPropertySet = AddPropertySet(ifcTypeObject, pSetName, description);
                }
            }
            else
            {
                if (IfcProducts == null)
                {
                    IfcProducts = Model.Instances.OfType <IfcProduct>();
                }
                IfcProduct ifcProduct = IfcProducts.Where(to => to.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                if (ifcProduct != null)
                {
                    if (XBimContext.IsMerge)
                    {
                        ifcPropertySet = ifcProduct.GetPropertySet(pSetName);
                        if (ifcPropertySet != null)//Property set Pset_EnvironmentalImpactValues already set so assume exists so skip
                        {
#if DEBUG
                            Console.WriteLine("{0} Pset_EnvironmentalImpactValues Property set so skip on merge", ifcProduct.GetType().Name);
#endif
                            return;
                        }
                    }

                    ifcPropertySet = AddPropertySet(ifcProduct, pSetName, description);
                }
            }

            //check we have a property set from the found SheetName/RowName object
            if (ifcPropertySet != null)
            {
                //Add Created By, Created On and ExtSystem to Owner History.
                SetUserHistory(ifcPropertySet, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                //using statement will set the Model.OwnerHistoryAddObject to ifcPropertySet.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, ifcPropertySet.OwnerHistory))
                {
                    if (ValidateString(row.Name))
                    {
                        AddPropertySingleValue(ifcPropertySet, "ImpactName", "Impact Name", new IfcText(row.Name), null);
                    }

                    if (ValidateString(row.ImpactType))
                    {
                        AddPropertySingleValue(ifcPropertySet, "ImpactType", "Impact Type", new IfcText(row.ImpactType), null);
                    }

                    if (ValidateString(row.ImpactStage))
                    {
                        AddPropertySingleValue(ifcPropertySet, "ImpactStage", "Impact Stage", new IfcText(row.ImpactStage), null);
                    }

                    if (ValidateString(row.Value))
                    {
                        IfcValue ifcValue = SetValue(row.Value);

                        IfcUnit ifcUnit = null;
                        if (ValidateString(row.ImpactUnit))
                        {
                            ifcUnit = GetDurationUnit(row.ImpactUnit); //see if time unit
                            //see if we can convert to a IfcSIUnit
                            if (ifcUnit == null)
                            {
                                ifcUnit = GetSIUnit(row.ImpactUnit);
                            }
                            //OK set as a user defined
                            if (ifcUnit == null)
                            {
                                ifcUnit = SetContextDependentUnit(row.ImpactUnit);
                            }
                        }
                        AddPropertySingleValue(ifcPropertySet, "Value", "Value", ifcValue, ifcUnit);
                    }

                    if (ValidateString(row.LeadInTime))
                    {
                        IfcValue ifcValue = SetValue(row.LeadInTime);
                        AddPropertySingleValue(ifcPropertySet, "LeadInTime", "Lead In Time", ifcValue, null);
                    }

                    if (ValidateString(row.Duration))
                    {
                        IfcValue ifcValue = SetValue(row.Duration);
                        AddPropertySingleValue(ifcPropertySet, "Duration", "Duration", ifcValue, null);
                    }

                    if (ValidateString(row.LeadOutTime))
                    {
                        IfcValue ifcValue = SetValue(row.LeadOutTime);
                        AddPropertySingleValue(ifcPropertySet, "LeadOutTime", "Lead Out Time", ifcValue, null);
                    }

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcPropertySet);

                    //row.Description done above on property set
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Add the data to the IfcTask object
        /// </summary>
        /// <param name="row">COBieJobRow holding the data</param>
        private void AddJob(COBieJobRow row)
        {
            IEnumerable<IfcTypeObject> ifcTypeObjects = Enumerable.Empty<IfcTypeObject>();
            IfcTask ifcTask = null;
            
            //get the objects in the typeName cell
            if (ValidateString(row.TypeName))
            {
                List<string> typeNames = SplitString(row.TypeName, ':');
                ifcTypeObjects = IfcTypeObjects.Where(to => typeNames.Contains(to.Name.ToString().Trim()));
            }

            //if merging check for existing task
            if (XBimContext.IsMerge)
            {
                string taskNo = string.Empty;
                //get the task ID
                if (ValidateString(row.TaskNumber)) 
                    taskNo = row.TaskNumber;
                //see if task matches name and task number
                ifcTask = CheckIfObjExistOnMerge<IfcTask>(row.Name).Where(task => task.TaskId == taskNo).FirstOrDefault();
                if (ifcTask != null)
                {
                    IfcRelAssignsToProcess processRel = Model.Instances.Where<IfcRelAssignsToProcess>(rd => rd.RelatingProcess == ifcTask).FirstOrDefault();
                    int matchCount = ifcTypeObjects.Count(to => processRel.RelatedObjects.Contains(to));
                    if (matchCount == ifcTypeObjects.Count()) //task IfcRelAssignsToProcess object hold the correct number of ifcTypeObjects objects so consider a match
                        return; //consider a match so return
                    
                }
            }

            //no match on task    
            ifcTask = Model.Instances.New<IfcTask>();
            
            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcTask, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
            //using statement will set the Model.OwnerHistoryAddObject to ifcConstructionEquipmentResource.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, ifcTask.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name)) ifcTask.Name = row.Name;

                //Add Category
                if (ValidateString(row.Category)) ifcTask.ObjectType = row.Category;

                //AddStatus
                if (ValidateString(row.Status)) ifcTask.Status = row.Status;

                //Add Type Relationship
                if (ifcTypeObjects.Any())
                {
                    SetRelAssignsToProcess(ifcTask, ifcTypeObjects);
                }
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcTask);

                //add Description
                if (ValidateString(row.Description)) ifcTask.Description = row.Description;

               
                //Add Duration and duration Unit
                if (ValidateString(row.Duration))
                {
                    IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTask, "Pset_Job_COBie", "Job Properties From COBie", "TaskDuration", "Task Duration", new IfcReal(row.Duration));
                    //DurationUnit
                    if (ValidateString(row.DurationUnit))
                        ifcPropertySingleValue.Unit = GetDurationUnit(row.DurationUnit);
                }

                //Add start time and start unit
                if (ValidateString(row.Start))
                {
                    IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTask, "Pset_Job_COBie", null, "TaskStartDate", "Task Start Date", new IfcText(row.Start));
                    //TaskStartUnit
                    if (ValidateString(row.TaskStartUnit))
                        ifcPropertySingleValue.Unit = GetDurationUnit(row.TaskStartUnit);
                }

                //Add frequency and frequency unit
                if (ValidateString(row.Frequency))
                {
                    IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTask, "Pset_Job_COBie", null, "TaskInterval", "Task Interval", new IfcReal(row.Frequency));
                    //TaskStartUnit
                    if (ValidateString(row.FrequencyUnit))
                        ifcPropertySingleValue.Unit = GetDurationUnit(row.FrequencyUnit);
                } 
                
                //Add Task ID
                if (ValidateString(row.TaskNumber)) ifcTask.TaskId = row.TaskNumber;

                //Add Priors, done in another loop see above

                //Add Resource names
                if (ValidateString(row.ResourceNames))
                {
                    List<string> Resources = row.ResourceNames.Split(',').ToList<string>(); //did dangerous using , as ',' as user can easily place out of sequence.
                    for (int i = 0; i < Resources.Count; i++)
                    {
                        Resources[i] = Resources[i].ToLower().Trim().Replace(".", string.Empty); //remove full stop
                    }
                    IEnumerable<IfcConstructionEquipmentResource> ifcConstructionEquipmentResource = IfcConstructionEquipmentResources.Where(cer => Resources.Contains(cer.Name.ToString().ToLower().Trim().Replace(".", string.Empty)));
                    if (ifcConstructionEquipmentResource != null) 
                        SetRelAssignsToProcess(ifcTask, ifcConstructionEquipmentResource);
                   
                }

            }
        }
Пример #28
0
        /// <summary>
        /// Add the data to the Type object
        /// </summary>
        /// <param name="row">COBieTypeRow holding the data</param>
        private void AddType(COBieTypeRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge<IfcTypeObject>(row.Name))
            {
                return;//we have it so no need to create
            }

            IfcTypeObject ifcTypeObject = GetTypeInstance(row.ExtObject, Model);

            if (ifcTypeObject != null)
            {
                //Add Created By, Created On and ExtSystem to Owner History. 
                SetUserHistory(ifcTypeObject, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
                //using statement will set the Model.OwnerHistoryAddObject to ifcTypeObject.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, ifcTypeObject.OwnerHistory))
                {
                    string name = row.Name;
                    //Add Name
                    if (ValidateString(row.Name)) ifcTypeObject.Name = row.Name;

                    //Add Category
                    AddCategory(row.Category, ifcTypeObject);

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcTypeObject);

                    //Add Description
                    if (ValidateString(row.Description)) ifcTypeObject.Description = row.Description;

                    if (ValidateString(row.AssetType))
                        AddPropertySingleValue(ifcTypeObject, "Pset_Asset", "Type Asset Fixed or Movable Properties From COBie", "AssetAccountingType", "Asset Type Fixed or Movable", new IfcLabel(row.AssetType));
                    if (ValidateString(row.Manufacturer))
                        AddPropertySingleValue(ifcTypeObject, "Pset_ManufacturersTypeInformation", "Manufacturers Properties From COBie", "Manufacturer", "Manufacturer Contact for " + name, new IfcLabel(row.Manufacturer));
                    if (ValidateString(row.ModelNumber))
                        AddPropertySingleValue(ifcTypeObject, "Pset_ManufacturersTypeInformation", null, "ModelLabel", "Model Number for " + name, new IfcLabel(row.ModelNumber));
                    //reset property set name from "Pset_Warranty" via v16 matrix sheet to to "COBie_Warranty"
                    if (ValidateString(row.WarrantyGuarantorParts))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", "Warranty Information", "WarrantyGuarantorParts", "Warranty Contact for " + name, new IfcLabel(row.WarrantyGuarantorParts));
                    if (ValidateString(row.WarrantyDurationParts))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyDurationParts", "Warranty length for " + name, new IfcLabel(row.WarrantyDurationParts));
                    if (ValidateString(row.WarrantyGuarantorLabor))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyGuarantorLabor", "Warranty Labour Contact for " + name, new IfcLabel(row.WarrantyGuarantorLabor));
                    if (ValidateString(row.WarrantyDescription))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyDescription", "Warranty Description for" + name, new IfcLabel(row.WarrantyDescription));

                    if (ValidateString(row.WarrantyDurationLabor))
                    {
                        IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyDurationLabor", "Labour Warranty length for " + name, new IfcLabel(row.WarrantyDurationLabor));
                        //WarrantyDurationUnit
                        if (ValidateString(row.WarrantyDurationUnit))
                            ifcPropertySingleValue.Unit = GetDurationUnit(row.WarrantyDurationUnit);
                    }

                    if (ValidateString(row.ReplacementCost))
                    {
                        double? value = GetDoubleFromString(row.ReplacementCost);
                        if (value != null)
                            AddPropertySingleValue(ifcTypeObject, "Pset_EconomicImpactValues", "Economic Impact Values", "ReplacementCost", "Replacement Cost for" + name, new IfcReal((double)value));
                    }
                    if (ValidateString(row.ExpectedLife))
                    {
                        IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTypeObject, "Pset_ServiceLife", "Service Life", "ServiceLifeDuration", "Service Life length for " + name, new IfcLabel(row.ExpectedLife));
                        if (ValidateString(row.DurationUnit))
                            ifcPropertySingleValue.Unit = GetDurationUnit(row.DurationUnit);
                    }
                    //changed from "Pset_Specification" via v16 matrix sheet to "COBie_Specification"
                    if (ValidateString(row.NominalLength))
                    {
                        double? value = GetDoubleFromString(row.NominalLength);
                        if (value != null)
                            AddPropertySingleValue(ifcTypeObject, "COBie_Specification", "Specification Properties", "NominalLength", "Nominal Length Value for " + name, new IfcReal((double)value));
                    }
                    if (ValidateString(row.NominalWidth))
                    {
                        double? value = GetDoubleFromString(row.NominalWidth);
                        if (value != null)
                            AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "NominalWidth", "Nominal Width Value for " + name, new IfcReal((double)value));
                    }
                    if (ValidateString(row.NominalHeight))
                    {
                        double? value = GetDoubleFromString(row.NominalHeight);
                        if (value != null)
                            AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "NominalHeight", "Nominal Height Value for " + name, new IfcReal((double)value));
                    }

                    if (ValidateString(row.ModelReference))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "ModelReference", "Model Reference Value for " + name, new IfcLabel(row.ModelReference));

                    if (ValidateString(row.Shape))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Shape", "Shape Value for " + name, new IfcLabel(row.Shape));

                    if (ValidateString(row.Size))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Size", "Size Value for " + name, new IfcLabel(row.Size));

                    if (ValidateString(row.Color))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Color", "Color Value for " + name, new IfcLabel(row.Color));

                    if (ValidateString(row.Finish))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Finish", "Finish Value for " + name, new IfcLabel(row.Finish));

                    if (ValidateString(row.Grade))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Grade", "Grade Value for " + name, new IfcLabel(row.Grade));

                    if (ValidateString(row.Material))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Material", "Material Value for " + name, new IfcLabel(row.Material));

                    if (ValidateString(row.Constituents))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Constituents", "Constituents Value for " + name, new IfcLabel(row.Constituents));

                    if (ValidateString(row.Features))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Features", "Features Value for " + name, new IfcLabel(row.Features));

                    if (ValidateString(row.AccessibilityPerformance))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "AccessibilityPerformance", "Accessibility Performance Value for " + name, new IfcLabel(row.AccessibilityPerformance));

                    if (ValidateString(row.CodePerformance))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "CodePerformance", "Code Performance Value for " + name, new IfcLabel(row.CodePerformance));

                    if (ValidateString(row.SustainabilityPerformance))
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "SustainabilityPerformance", "Sustainability Performance Value for " + name, new IfcLabel(row.SustainabilityPerformance));


                }
            }
            else
            {
#if DEBUG
                Console.WriteLine("Failed to create type {0} of {1}", row.Name, row.ExtObject);
#endif
            }


        }
Пример #29
0
        /// <summary>
        /// Add the data to the Type object
        /// </summary>
        /// <param name="row">COBieTypeRow holding the data</param>
        private void AddType(COBieTypeRow row)
        {
            //we are merging so check for an existing item name, assume the same item as should be the same building
            if (CheckIfExistOnMerge <IfcTypeObject>(row.Name))
            {
                return;//we have it so no need to create
            }

            IfcTypeObject ifcTypeObject = GetTypeInstance(row.ExtObject, Model);

            if (ifcTypeObject != null)
            {
                //Add Created By, Created On and ExtSystem to Owner History.
                SetUserHistory(ifcTypeObject, row.ExtSystem, row.CreatedBy, row.CreatedOn);

                //using statement will set the Model.OwnerHistoryAddObject to ifcTypeObject.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, ifcTypeObject.OwnerHistory))
                {
                    string name = row.Name;
                    //Add Name
                    if (ValidateString(row.Name))
                    {
                        ifcTypeObject.Name = row.Name;
                    }

                    //Add Category
                    AddCategory(row.Category, ifcTypeObject);

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcTypeObject);

                    //Add Description
                    if (ValidateString(row.Description))
                    {
                        ifcTypeObject.Description = row.Description;
                    }

                    if (ValidateString(row.AssetType))
                    {
                        AddPropertySingleValue(ifcTypeObject, "Pset_Asset", "Type Asset Fixed or Movable Properties From COBie", "AssetAccountingType", "Asset Type Fixed or Movable", new IfcLabel(row.AssetType));
                    }
                    if (ValidateString(row.Manufacturer))
                    {
                        AddPropertySingleValue(ifcTypeObject, "Pset_ManufacturersTypeInformation", "Manufacturers Properties From COBie", "Manufacturer", "Manufacturer Contact for " + name, new IfcLabel(row.Manufacturer));
                    }
                    if (ValidateString(row.ModelNumber))
                    {
                        AddPropertySingleValue(ifcTypeObject, "Pset_ManufacturersTypeInformation", null, "ModelLabel", "Model Number for " + name, new IfcLabel(row.ModelNumber));
                    }
                    //reset property set name from "Pset_Warranty" via v16 matrix sheet to to "COBie_Warranty"
                    if (ValidateString(row.WarrantyGuarantorParts))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", "Warranty Information", "WarrantyGuarantorParts", "Warranty Contact for " + name, new IfcLabel(row.WarrantyGuarantorParts));
                    }
                    if (ValidateString(row.WarrantyDurationParts))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyDurationParts", "Warranty length for " + name, new IfcLabel(row.WarrantyDurationParts));
                    }
                    if (ValidateString(row.WarrantyGuarantorLabor))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyGuarantorLabor", "Warranty Labour Contact for " + name, new IfcLabel(row.WarrantyGuarantorLabor));
                    }
                    if (ValidateString(row.WarrantyDescription))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyDescription", "Warranty Description for" + name, new IfcLabel(row.WarrantyDescription));
                    }

                    if (ValidateString(row.WarrantyDurationLabor))
                    {
                        IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTypeObject, "COBie_Warranty", null, "WarrantyDurationLabor", "Labour Warranty length for " + name, new IfcLabel(row.WarrantyDurationLabor));
                        //WarrantyDurationUnit
                        if (ValidateString(row.WarrantyDurationUnit))
                        {
                            ifcPropertySingleValue.Unit = GetDurationUnit(row.WarrantyDurationUnit);
                        }
                    }

                    if (ValidateString(row.ReplacementCost))
                    {
                        double?value = GetDoubleFromString(row.ReplacementCost);
                        if (value != null)
                        {
                            AddPropertySingleValue(ifcTypeObject, "Pset_EconomicImpactValues", "Economic Impact Values", "ReplacementCost", "Replacement Cost for" + name, new IfcReal((double)value));
                        }
                    }
                    if (ValidateString(row.ExpectedLife))
                    {
                        IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTypeObject, "Pset_ServiceLife", "Service Life", "ServiceLifeDuration", "Service Life length for " + name, new IfcLabel(row.ExpectedLife));
                        if (ValidateString(row.DurationUnit))
                        {
                            ifcPropertySingleValue.Unit = GetDurationUnit(row.DurationUnit);
                        }
                    }
                    //changed from "Pset_Specification" via v16 matrix sheet to "COBie_Specification"
                    if (ValidateString(row.NominalLength))
                    {
                        double?value = GetDoubleFromString(row.NominalLength);
                        if (value != null)
                        {
                            AddPropertySingleValue(ifcTypeObject, "COBie_Specification", "Specification Properties", "NominalLength", "Nominal Length Value for " + name, new IfcReal((double)value));
                        }
                    }
                    if (ValidateString(row.NominalWidth))
                    {
                        double?value = GetDoubleFromString(row.NominalWidth);
                        if (value != null)
                        {
                            AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "NominalWidth", "Nominal Width Value for " + name, new IfcReal((double)value));
                        }
                    }
                    if (ValidateString(row.NominalHeight))
                    {
                        double?value = GetDoubleFromString(row.NominalHeight);
                        if (value != null)
                        {
                            AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "NominalHeight", "Nominal Height Value for " + name, new IfcReal((double)value));
                        }
                    }

                    if (ValidateString(row.ModelReference))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "ModelReference", "Model Reference Value for " + name, new IfcLabel(row.ModelReference));
                    }

                    if (ValidateString(row.Shape))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Shape", "Shape Value for " + name, new IfcLabel(row.Shape));
                    }

                    if (ValidateString(row.Size))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Size", "Size Value for " + name, new IfcLabel(row.Size));
                    }

                    if (ValidateString(row.Color))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Color", "Color Value for " + name, new IfcLabel(row.Color));
                    }

                    if (ValidateString(row.Finish))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Finish", "Finish Value for " + name, new IfcLabel(row.Finish));
                    }

                    if (ValidateString(row.Grade))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Grade", "Grade Value for " + name, new IfcLabel(row.Grade));
                    }

                    if (ValidateString(row.Material))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Material", "Material Value for " + name, new IfcLabel(row.Material));
                    }

                    if (ValidateString(row.Constituents))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Constituents", "Constituents Value for " + name, new IfcLabel(row.Constituents));
                    }

                    if (ValidateString(row.Features))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "Features", "Features Value for " + name, new IfcLabel(row.Features));
                    }

                    if (ValidateString(row.AccessibilityPerformance))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "AccessibilityPerformance", "Accessibility Performance Value for " + name, new IfcLabel(row.AccessibilityPerformance));
                    }

                    if (ValidateString(row.CodePerformance))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "CodePerformance", "Code Performance Value for " + name, new IfcLabel(row.CodePerformance));
                    }

                    if (ValidateString(row.SustainabilityPerformance))
                    {
                        AddPropertySingleValue(ifcTypeObject, "COBie_Specification", null, "SustainabilityPerformance", "Sustainability Performance Value for " + name, new IfcLabel(row.SustainabilityPerformance));
                    }
                }
            }
            else
            {
#if DEBUG
                Console.WriteLine("Failed to create type {0} of {1}", row.Name, row.ExtObject);
#endif
            }
        }
Пример #30
0
        /// <summary>
        /// Add the data to the IfcRelConnectsElements object
        /// </summary>
        /// <param name="row">COBieConnectionRow holding the data</param>
        private void AddConnection(COBieConnectionRow row)
        {
            IfcElement             relatingElement        = null;
            IfcElement             relatedElement         = null;
            IfcRelConnectsElements ifcRelConnectsElements = null;

            if (ValidateString(row.RowName1))
            {
                relatingElement = GetElement(row.RowName1);
            }

            if (ValidateString(row.RowName2))
            {
                relatedElement = GetElement(row.RowName2);
            }

            //check on merge that we have not already created the IfcRelConnectsElements object
            ifcRelConnectsElements = CheckIfObjExistOnMerge <IfcRelConnectsElements>(row.Name).Where(rce => (rce.RelatingElement == relatingElement) && (rce.RelatedElement == relatedElement)).FirstOrDefault();
            if (ifcRelConnectsElements != null)
            {
                return; //we have this object so return, make assumption that ports will also have exist!
            }

            if (ifcRelConnectsElements == null)
            {
                ifcRelConnectsElements = Model.Instances.New <IfcRelConnectsElements>();
            }

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcRelConnectsElements, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to ifcRelConnectsElements.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, ifcRelConnectsElements.OwnerHistory))
            {
                if (ValidateString(row.Name))
                {
                    ifcRelConnectsElements.Name = row.Name;
                }
                if (ValidateString(row.ConnectionType))
                {
                    ifcRelConnectsElements.Description = row.ConnectionType;
                }

                if (relatingElement != null)
                {
                    ifcRelConnectsElements.RelatingElement = relatingElement;
                }

                if (relatedElement != null)
                {
                    ifcRelConnectsElements.RelatedElement = relatedElement;
                }


                //Add Ports
                AddRelConnectsPorts(row.RealizingElement, row.PortName1, row.PortName2, relatingElement, relatedElement);

                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcRelConnectsElements);

                if (!ValidateString(ifcRelConnectsElements.Description))
                {
                    ifcRelConnectsElements.Description = row.Description;
                }
            }
        }
Пример #31
0
        /// <summary>
        /// Add the Impact and fill with data from COBieComponentRow
        /// </summary>
        /// <param name="row">COBieImpactRow holding the data</param>
        private void AddImpact(COBieImpactRow row)
        {
            string pSetName = "Pset_EnvironmentalImpactValues";
            string description = Constants.DEFAULT_STRING;
            if (ValidateString(row.Description))
                description = row.Description;

            IfcPropertySet ifcPropertySet = null;
            if (row.SheetName.ToLower().Trim() == "type")
            {
                if (IfcTypeObjects == null)
                            IfcTypeObjects = Model.Instances.OfType<IfcTypeObject>();
                IfcTypeObject ifcTypeObject = IfcTypeObjects.Where(to => to.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                if (ifcTypeObject != null)
                {
                    if (XBimContext.IsMerge)
                    {
                        ifcPropertySet = ifcTypeObject.GetPropertySet(pSetName);
                        if (ifcPropertySet != null) //Property set Pset_EnvironmentalImpactValues already set so assume exists so skip
                        {
#if DEBUG
                            Console.WriteLine("{0} Pset_EnvironmentalImpactValues Property set so skip on merge", ifcTypeObject.GetType().Name);
#endif
                            return;
                        }
                    }
                    
                    ifcPropertySet = AddPropertySet(ifcTypeObject, pSetName, description);
                }
            }
            else
            {
                if (IfcProducts == null)
                    IfcProducts = Model.Instances.OfType<IfcProduct>();
                IfcProduct ifcProduct = IfcProducts.Where(to => to.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                if (ifcProduct != null)
                {
                    if (XBimContext.IsMerge)
                    {
                        ifcPropertySet = ifcProduct.GetPropertySet(pSetName);
                        if (ifcPropertySet != null)//Property set Pset_EnvironmentalImpactValues already set so assume exists so skip
                        {
#if DEBUG
                            Console.WriteLine("{0} Pset_EnvironmentalImpactValues Property set so skip on merge", ifcProduct.GetType().Name);
#endif
                            return;
                        }
                           
                    }
                    
                    ifcPropertySet = AddPropertySet(ifcProduct, pSetName, description);
                }
            }

            //check we have a property set from the found SheetName/RowName object
            if (ifcPropertySet != null)
            {
                //Add Created By, Created On and ExtSystem to Owner History. 
                SetUserHistory(ifcPropertySet, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                //using statement will set the Model.OwnerHistoryAddObject to ifcPropertySet.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, ifcPropertySet.OwnerHistory))
                {
                    if (ValidateString(row.Name))
                        AddPropertySingleValue(ifcPropertySet, "ImpactName", "Impact Name", new IfcText(row.Name), null);
                    
                    if (ValidateString(row.ImpactType))
                        AddPropertySingleValue(ifcPropertySet, "ImpactType", "Impact Type", new IfcText(row.ImpactType), null);
                    
                    if (ValidateString(row.ImpactStage))
                        AddPropertySingleValue(ifcPropertySet, "ImpactStage", "Impact Stage", new IfcText(row.ImpactStage), null);

                    if (ValidateString(row.Value))
                    {
                        IfcValue ifcValue = SetValue(row.Value);
                        
                        IfcUnit ifcUnit = null;
                        if (ValidateString(row.ImpactUnit))
                        {
                            ifcUnit = GetDurationUnit(row.ImpactUnit); //see if time unit
                            //see if we can convert to a IfcSIUnit
                            if (ifcUnit == null)
                                ifcUnit = GetSIUnit(row.ImpactUnit);
                            //OK set as a user defined
                            if (ifcUnit == null)
                                ifcUnit = SetContextDependentUnit(row.ImpactUnit);
                        }
                        AddPropertySingleValue(ifcPropertySet, "Value", "Value", ifcValue, ifcUnit);
                    }

                    if (ValidateString(row.LeadInTime))
                    {
                        IfcValue ifcValue = SetValue(row.LeadInTime);
                        AddPropertySingleValue(ifcPropertySet, "LeadInTime", "Lead In Time", ifcValue, null);
                    }

                    if (ValidateString(row.Duration))
                    {
                        IfcValue ifcValue = SetValue(row.Duration);
                        AddPropertySingleValue(ifcPropertySet, "Duration", "Duration", ifcValue, null);
                    }

                    if (ValidateString(row.LeadOutTime))
                    {
                        IfcValue ifcValue = SetValue(row.LeadOutTime);
                        AddPropertySingleValue(ifcPropertySet, "LeadOutTime", "Lead Out Time", ifcValue, null);
                    }

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcPropertySet);

                    //row.Description done above on property set
                }
                
            }
            
        }
Пример #32
0
        /// <summary>
        /// SetUp the Model Project Object
        /// </summary>
        /// <param name="row">COBieFacilityRow object to read data from</param>
        private void SetUpProject(COBieFacilityRow row)
        {
            IfcProject ifcProject = Model.IfcProject;
            ifcProject.Initialize(ProjectUnits.SIUnitsUK);
            SetOwnerHistory(ifcProject, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn);
            //using statement will set the Model.OwnerHistoryAddObject to ifcProject.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, ifcProject.OwnerHistory))
            {
                if (ValidateString(row.ProjectName))
                    ifcProject.Name = row.ProjectName;

                if (ValidateString(row.ProjectDescription))
                    ifcProject.Description = row.ProjectDescription;
                if (ValidateString(row.Phase))
                    ifcProject.Phase = row.Phase;
                if (ValidateString(row.LinearUnits))
                {
                    SetUnitToProject(IfcUnitEnum.LENGTHUNIT, row.LinearUnits);

                }

                AddGlobalId(row.ExternalProjectIdentifier, ifcProject);


                if (ValidateString(row.AreaUnits))
                {
                    SetUnitToProject(IfcUnitEnum.AREAUNIT, row.AreaUnits);

                }

                if (ValidateString(row.VolumeUnits))
                {
                    SetUnitToProject(IfcUnitEnum.VOLUMEUNIT, row.VolumeUnits);

                }

                if (ValidateString(row.CurrencyUnit))
                {
                    SetMonetaryUnit(row.CurrencyUnit);
                }
            }
            
        }
Пример #33
0
        /// <summary>
        /// Add the data to the IfcRelDecomposes object
        /// </summary>
        /// <param name="row">COBieAssemblyRow holding the data</param>
        private void AddAssembly(COBieAssemblyRow row)
        {
            //check we have a chance of creating the IfcRelDecomposes object
            if ((ValidateString(row.ParentName)) && (ValidateString(row.ChildNames)))
            {
                IfcRelDecomposes ifcRelDecomposes = null;

                if ((LastIfcRelDecomposes != null) && IsContinuedAssemblyRow(row)) //this row line is a continuation of objects from the line above
                {
                    ifcRelDecomposes = LastIfcRelDecomposes;
                }
                else
                {
                    IfcObjectDefinition relatingObject = GetParentObject(row.ParentName);
                    //check on merge we have not already created using name and parent object as check
                    if (ValidateString(row.Name))
                    {
                        string testName = row.Name.ToLower().Trim();
                        ifcRelDecomposes = Model.Instances.Where<IfcRelDecomposes>(rc => (rc.Name.ToString().ToLower().Trim() == testName) && (rc.RelatingObject == relatingObject)).FirstOrDefault();
                    }

                    if ((ifcRelDecomposes == null) && (relatingObject != null))
                    {
                        if (row.ExtObject.ToLower().Trim() == "ifcrelnests")
                            ifcRelDecomposes = Model.Instances.New<IfcRelNests>();
                        else
                            ifcRelDecomposes = Model.Instances.New<IfcRelAggregates>();


                        //Add Created By, Created On and ExtSystem to Owner History. 
                        SetUserHistory(ifcRelDecomposes, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                    }
                    if (relatingObject == null)
                    {
                        Console.WriteLine(string.Format("Failed to find ifcRelDecomposes parent object in AddAssembly() for {0}", row.Name.ToString()));
                        return;
                    }
                }

                

                //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.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, ifcRelDecomposes.OwnerHistory))
                {
                    if (ValidateString(row.Name)) ifcRelDecomposes.Name = row.Name;
                    if (ValidateString(row.Description)) ifcRelDecomposes.Description = row.Description;

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcRelDecomposes);
                        
                    if (! (AddParentObject(ifcRelDecomposes, row.ParentName) &&
                           AddChildObjects(ifcRelDecomposes, row.SheetName, row.ChildNames)
                           )
                        )
                    {
                        //failed to add parent or child so remove as not a valid IfcRelDecomposes object
                        try
                        {
                            Model.Delete(ifcRelDecomposes);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(string.Format("Failed to delete ifcRelDecomposes in AddAssembly() - {0}", ex.Message));
                            
                        }
                        ifcRelDecomposes = null;
                    }
                    
                }
                //save for next row, might be a continuation line
                LastIfcRelDecomposes = ifcRelDecomposes;
            }
        }
        /// <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
                }
            }
        }
Пример #35
0
        /// <summary>
        /// Add an IfcApproval to the model based on COBieIssueRow data
        /// </summary>
        /// <param name="row">COBieIssueRow data</param>
        private void AddIssue(COBieIssueRow row)
        {

            if (CheckIfExistOnMerge(row)) //check on merge to see if IfcApproval exists
                return; //already exists

            //create the property set to attach to the approval
            IfcPropertySet ifcPropertySet = Model.Instances.New<IfcPropertySet>();
            ifcPropertySet.Name = "Pset_Risk";
            ifcPropertySet.Description = "An indication of exposure to mischance, peril, menace, hazard or loss";
           

            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcPropertySet, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
            //using statement will set the Model.OwnerHistoryAddObject to ifcPropertySet.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, ifcPropertySet.OwnerHistory))
            {
                //create the approval object
                IfcApproval ifcApproval = Model.Instances.New<IfcApproval>();
                //set relationship
                IfcRelAssociatesApproval ifcRelAssociatesApproval = Model.Instances.New<IfcRelAssociatesApproval>();
                ifcRelAssociatesApproval.RelatingApproval = ifcApproval;
                ifcRelAssociatesApproval.RelatedObjects.Add_Reversible(ifcPropertySet);

                if (ValidateString(row.Name))
                    ifcApproval.Name = row.Name;

                if (ValidateString(row.Type))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Type);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskType", "Identifies the predefined types of risk from which the type required may be set.", ifcValues, _riskTypeEnum, null);
                }

                if (ValidateString(row.Risk))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Risk);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskRating", "Rating of the risk that may be determined from a combination of the risk assessment and risk consequence.", ifcValues, _riskRatingEnum, null);
                }

                if (ValidateString(row.Chance))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Chance);
                    AddPropertyEnumeratedValue(ifcPropertySet, "AssessmentOfRisk", "Likelihood of risk event occurring.", ifcValues, _assessmentOfRiskEnum, null);
                }

                if (ValidateString(row.Impact))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Impact);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskConsequence", "Indicates the level of severity of the consequences that the risk would have in case it happens.", ifcValues, _riskConsequenceEnum, null);
                }

                if (ValidateString(row.SheetName1) && ValidateString(row.RowName1))
                {
                    SetRelObjectToApproval(row.SheetName1, row.RowName1,  ifcApproval,  ifcRelAssociatesApproval);
                }

                if (ValidateString(row.SheetName2) && ValidateString(row.RowName2))
                {
                    SetRelObjectToApproval(row.SheetName2, row.RowName2, ifcApproval, ifcRelAssociatesApproval);
                }

                if (ValidateString(row.Description))
                    ifcApproval.Description = row.Description;

                if (ValidateString(row.Owner))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Owner);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskOwner", "A determination of who is the owner of the risk by reference to principal roles of organizations within a project.", ifcValues, _riskOwnerEnum, null);
                }

                if (ValidateString(row.Mitigation))
                    AddPropertySingleValue(ifcPropertySet, "PreventiveMeassures", "Identifies preventive measures to be taken to mitigate risk.", new IfcText(row.Mitigation), null);

                //Add Identifier
                if (ValidateString(row.ExtIdentifier))
                    ifcApproval.Identifier = row.ExtIdentifier; // AddGlobalId(row.ExtIdentifier, ifcPropertySet); //IfcApproval gas no GlobalId
            }
        }
Пример #36
0
        /// <summary>
        /// Add the data to the IfcRelDecomposes object
        /// </summary>
        /// <param name="row">COBieAssemblyRow holding the data</param>
        private void AddAssembly(COBieAssemblyRow row)
        {
            //check we have a chance of creating the IfcRelDecomposes object
            if ((ValidateString(row.ParentName)) && (ValidateString(row.ChildNames)))
            {
                IfcRelDecomposes ifcRelDecomposes = null;

                if ((LastIfcRelDecomposes != null) && IsContinuedAssemblyRow(row)) //this row line is a continuation of objects from the line above
                {
                    ifcRelDecomposes = LastIfcRelDecomposes;
                }
                else
                {
                    IfcObjectDefinition relatingObject = GetParentObject(row.ParentName);
                    //check on merge we have not already created using name and parent object as check
                    if (ValidateString(row.Name))
                    {
                        string testName = row.Name.ToLower().Trim();
                        ifcRelDecomposes = Model.FederatedInstances.Where <IfcRelDecomposes>(rc => (rc.Name.ToString().ToLower().Trim() == testName) && (rc.RelatingObject == relatingObject)).FirstOrDefault();
                    }

                    if ((ifcRelDecomposes == null) && (relatingObject != null))
                    {
                        if (row.ExtObject.ToLower().Trim() == "ifcrelnests")
                        {
                            ifcRelDecomposes = Model.Instances.New <IfcRelNests>();
                        }
                        else
                        {
                            ifcRelDecomposes = Model.Instances.New <IfcRelAggregates>();
                        }


                        //Add Created By, Created On and ExtSystem to Owner History.
                        SetUserHistory(ifcRelDecomposes, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                    }
                    if (relatingObject == null)
                    {
                        Console.WriteLine(string.Format("Failed to find ifcRelDecomposes parent object in AddAssembly() for {0}", row.Name.ToString()));
                        return;
                    }
                }



                //using statement will set the Model.OwnerHistoryAddObject to IfcConstructionProductResource.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, ifcRelDecomposes.OwnerHistory))
                {
                    if (ValidateString(row.Name))
                    {
                        ifcRelDecomposes.Name = row.Name;
                    }
                    if (ValidateString(row.Description))
                    {
                        ifcRelDecomposes.Description = row.Description;
                    }

                    //Add GlobalId
                    AddGlobalId(row.ExtIdentifier, ifcRelDecomposes);

                    if (!(AddParentObject(ifcRelDecomposes, row.ParentName) &&
                          AddChildObjects(ifcRelDecomposes, row.SheetName, row.ChildNames)
                          )
                        )
                    {
                        //failed to add parent or child so remove as not a valid IfcRelDecomposes object
                        try
                        {
                            Model.Delete(ifcRelDecomposes);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(string.Format("Failed to delete ifcRelDecomposes in AddAssembly() - {0}", ex.Message));
                        }
                        ifcRelDecomposes = null;
                    }
                }
                //save for next row, might be a continuation line
                LastIfcRelDecomposes = ifcRelDecomposes;
            }
        }
Пример #37
0
        /// <summary>
        /// Add the data to the IfcRelConnectsElements object
        /// </summary>
        /// <param name="row">COBieConnectionRow holding the data</param>
        private void AddConnection(COBieConnectionRow row)
        {
            IfcElement relatingElement = null;
            IfcElement relatedElement = null;
            IfcRelConnectsElements ifcRelConnectsElements = null;
            if (ValidateString(row.RowName1))
                relatingElement = GetElement(row.RowName1);
           
            if (ValidateString(row.RowName2))
                relatedElement = GetElement(row.RowName2);

            //check on merge that we have not already created the IfcRelConnectsElements object
            ifcRelConnectsElements = CheckIfObjExistOnMerge<IfcRelConnectsElements>(row.Name).Where(rce => (rce.RelatingElement == relatingElement) && (rce.RelatedElement == relatedElement) ).FirstOrDefault();
            if (ifcRelConnectsElements != null)
            {
                return; //we have this object so return, make assumption that ports will also have exist!
            }

            if (ifcRelConnectsElements == null)
                ifcRelConnectsElements = Model.Instances.New<IfcRelConnectsElements>();
            
            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcRelConnectsElements, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                    
            //using statement will set the Model.OwnerHistoryAddObject to ifcRelConnectsElements.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, ifcRelConnectsElements.OwnerHistory))
            {
                if (ValidateString(row.Name)) ifcRelConnectsElements.Name = row.Name;
                if (ValidateString(row.ConnectionType)) ifcRelConnectsElements.Description = row.ConnectionType;

                if (relatingElement != null) 
                    ifcRelConnectsElements.RelatingElement = relatingElement;

                if (relatedElement != null)
                    ifcRelConnectsElements.RelatedElement = relatedElement;
                

                //Add Ports
                AddRelConnectsPorts(row.RealizingElement, row.PortName1, row.PortName2, relatingElement, relatedElement);
                
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcRelConnectsElements);

                if (!ValidateString(ifcRelConnectsElements.Description)) ifcRelConnectsElements.Description = row.Description;
            }
            
        }
Пример #38
0
        /// <summary>
        /// Create and setup the IfcBuilding building object
        /// </summary>
        /// <param name="row">COBieFacilityRow object to read data from</param>
        private void CreateBuilding(COBieFacilityRow row)
        {
            IfcBuilding ifcBuilding = Model.Instances.New<IfcBuilding>();
            SetNewOwnerHistory(ifcBuilding, row.ExternalSystem, Model.DefaultOwningUser, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to ifcBuilding.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, ifcBuilding.OwnerHistory))
            {
                AddGlobalId(row.ExternalFacilityIdentifier, ifcBuilding);
                if (ValidateString(row.Name))
                    ifcBuilding.Name = row.Name;
                //add category
                AddCategory(row.Category, ifcBuilding);

                if (ValidateString(row.Description))
                    ifcBuilding.Description = row.Description;
                if (ValidateString(row.AreaMeasurement))
                {
                    SetAreaMeasure(ifcBuilding, row);
                }

                ifcBuilding.CompositionType = IfcElementCompositionEnum.ELEMENT;
                IfcLocalPlacement lp = Model.Instances.New<IfcLocalPlacement>();
                lp.RelativePlacement = WCS;
                lp.PlacementRelTo = GetSite().ObjectPlacement;
                ifcBuilding.ObjectPlacement = lp;
               

            }
            
        }
Пример #39
0
        /// <summary>
        /// Add the data to the IfcTask object
        /// </summary>
        /// <param name="row">COBieJobRow holding the data</param>
        private void AddJob(COBieJobRow row)
        {
            IEnumerable <IfcTypeObject> ifcTypeObjects = Enumerable.Empty <IfcTypeObject>();
            IfcTask ifcTask = null;

            //get the objects in the typeName cell
            if (ValidateString(row.TypeName))
            {
                List <string> typeNames = SplitString(row.TypeName, ':');
                ifcTypeObjects = IfcTypeObjects.Where(to => typeNames.Contains(to.Name.ToString().Trim()));
            }

            //if merging check for existing task
            if (XBimContext.IsMerge)
            {
                string taskNo = string.Empty;
                //get the task ID
                if (ValidateString(row.TaskNumber))
                {
                    taskNo = row.TaskNumber;
                }
                //see if task matches name and task number
                ifcTask = CheckIfObjExistOnMerge <IfcTask>(row.Name).Where(task => task.TaskId == taskNo).FirstOrDefault();
                if (ifcTask != null)
                {
                    IfcRelAssignsToProcess processRel = Model.Instances.Where <IfcRelAssignsToProcess>(rd => rd.RelatingProcess == ifcTask).FirstOrDefault();
                    int matchCount = ifcTypeObjects.Count(to => processRel.RelatedObjects.Contains(to));
                    if (matchCount == ifcTypeObjects.Count()) //task IfcRelAssignsToProcess object hold the correct number of ifcTypeObjects objects so consider a match
                    {
                        return;                               //consider a match so return
                    }
                }
            }

            //no match on task
            ifcTask = Model.Instances.New <IfcTask>();

            //Add Created By, Created On and ExtSystem to Owner History.
            SetUserHistory(ifcTask, row.ExtSystem, row.CreatedBy, row.CreatedOn);

            //using statement will set the Model.OwnerHistoryAddObject to ifcConstructionEquipmentResource.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, ifcTask.OwnerHistory))
            {
                //Add Name
                if (ValidateString(row.Name))
                {
                    ifcTask.Name = row.Name;
                }

                //Add Category
                if (ValidateString(row.Category))
                {
                    ifcTask.ObjectType = row.Category;
                }

                //AddStatus
                if (ValidateString(row.Status))
                {
                    ifcTask.Status = row.Status;
                }

                //Add Type Relationship
                if (ifcTypeObjects.Any())
                {
                    SetRelAssignsToProcess(ifcTask, ifcTypeObjects);
                }
                //Add GlobalId
                AddGlobalId(row.ExtIdentifier, ifcTask);

                //add Description
                if (ValidateString(row.Description))
                {
                    ifcTask.Description = row.Description;
                }


                //Add Duration and duration Unit
                if (ValidateString(row.Duration))
                {
                    IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTask, "Pset_Job_COBie", "Job Properties From COBie", "TaskDuration", "Task Duration", new IfcReal(row.Duration));
                    //DurationUnit
                    if (ValidateString(row.DurationUnit))
                    {
                        ifcPropertySingleValue.Unit = GetDurationUnit(row.DurationUnit);
                    }
                }

                //Add start time and start unit
                if (ValidateString(row.Start))
                {
                    IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTask, "Pset_Job_COBie", null, "TaskStartDate", "Task Start Date", new IfcText(row.Start));
                    //TaskStartUnit
                    if (ValidateString(row.TaskStartUnit))
                    {
                        ifcPropertySingleValue.Unit = GetDurationUnit(row.TaskStartUnit);
                    }
                }

                //Add frequency and frequency unit
                if (ValidateString(row.Frequency))
                {
                    IfcPropertySingleValue ifcPropertySingleValue = AddPropertySingleValue(ifcTask, "Pset_Job_COBie", null, "TaskInterval", "Task Interval", new IfcReal(row.Frequency));
                    //TaskStartUnit
                    if (ValidateString(row.FrequencyUnit))
                    {
                        ifcPropertySingleValue.Unit = GetDurationUnit(row.FrequencyUnit);
                    }
                }

                //Add Task ID
                if (ValidateString(row.TaskNumber))
                {
                    ifcTask.TaskId = row.TaskNumber;
                }

                //Add Priors, done in another loop see above

                //Add Resource names
                if (ValidateString(row.ResourceNames))
                {
                    List <string> Resources = row.ResourceNames.Split(',').ToList <string>(); //did dangerous using , as ',' as user can easily place out of sequence.
                    for (int i = 0; i < Resources.Count; i++)
                    {
                        Resources[i] = Resources[i].ToLower().Trim().Replace(".", string.Empty); //remove full stop
                    }
                    IEnumerable <IfcConstructionEquipmentResource> ifcConstructionEquipmentResource = IfcConstructionEquipmentResources.Where(cer => Resources.Contains(cer.Name.ToString().ToLower().Trim().Replace(".", string.Empty)));
                    if (ifcConstructionEquipmentResource != null)
                    {
                        SetRelAssignsToProcess(ifcTask, ifcConstructionEquipmentResource);
                    }
                }
            }
        }
Пример #40
0
        /// <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.Instances.Where<IfcBuildingStorey>(bs => bs.GlobalId == id).FirstOrDefault();
            }

            if ((ifcBuildingStorey == null) && (ValidateString(row.RowName)))
            {
                ifcBuildingStorey = Model.Instances.Where<IfcBuildingStorey>(bs => bs.Name == row.RowName).FirstOrDefault();
            }

            if (ifcBuildingStorey != null)
            {
                IfcProduct placementRelToIfcProduct = ifcBuildingStorey.SpatialStructuralElementParent as IfcProduct;
                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;
                    }
                }
            }
        }