Example #1
0
        /// <summary>
        /// Get the parent object for the ifcRelDecomposes object
        /// </summary>
        /// <param name="parentName">Math the Name property with this string</param>
        /// <returns>IfcObjectDefinition </returns>
        private IfcObjectDefinition GetParentObject(string parentName)
        {
            string name = parentName.ToLower().Trim();
            IfcObjectDefinition RelatingObject = IfcElements.Where(obj => obj.Name.ToString().ToLower().Trim() == name).FirstOrDefault();

            if (RelatingObject == null) //try IfcTypeObjects
            {
                RelatingObject = IfcTypeObjects.Where(obj => obj.Name.ToString().ToLower().Trim() == name).FirstOrDefault();
            }
            return(RelatingObject);
        }
        /// <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
            }
        }
Example #3
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);
                    }
                }
            }
        }
        /// <summary>
        /// Add the properties to the row object
        /// </summary>
        /// <param name="row">COBieAttributeRow holding the data</param>
        private void AddAttribute(COBieAttributeRow row)
        {
            //need a sheet and a row to be able to attach property to an object
            if ((ValidateString(row.RowName)) && (ValidateString(row.SheetName)))
            {
                switch (row.SheetName.ToLower())
                {
                case "facility":
                    //set list if first time
                    if (IfcBuildings == null)
                    {
                        IfcBuildings = Model.Instances.OfType <IfcBuilding>();
                    }
                    if (!((CurrentObject is IfcBuilding) && (CurrentObject.Name == row.RowName)))
                    {
                        CurrentObject = IfcBuildings.Where(b => b.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                    }
                    break;

                case "floor":
                    if (IfcBuildingStoreys == null)
                    {
                        IfcBuildingStoreys = Model.Instances.OfType <IfcBuildingStorey>();
                    }
                    if (!((CurrentObject is IfcBuildingStorey) && (CurrentObject.Name == row.RowName)))
                    {
                        CurrentObject = IfcBuildingStoreys.Where(b => b.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                    }
                    break;

                case "space":
                    if (IfcSpaces == null)
                    {
                        IfcSpaces = Model.Instances.OfType <IfcSpace>();
                    }
                    if (!((CurrentObject is IfcSpace) && (CurrentObject.Name == row.RowName)))
                    {
                        CurrentObject = IfcSpaces.Where(b => b.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                    }
                    break;

                case "type":
                    if (IfcTypeObjects == null)
                    {
                        IfcTypeObjects = Model.Instances.OfType <IfcTypeObject>();
                    }
                    if (!((CurrentObject is IfcTypeObject) && (CurrentObject.Name == row.RowName)))
                    {
                        CurrentObject = IfcTypeObjects.Where(b => b.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                    }
                    break;

                case "spare":
                    if (IfcConstructionProductResources == null)
                    {
                        IfcConstructionProductResources = Model.Instances.OfType <IfcConstructionProductResource>();
                    }
                    if (!((CurrentObject is IfcConstructionProductResource) && (CurrentObject.Name == row.RowName)))
                    {
                        CurrentObject = IfcConstructionProductResources.Where(b => b.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                    }
                    break;

                case "component":
                    if (IfcElements == null)
                    {
                        IfcElements = Model.Instances.OfType <IfcElement>();
                    }
                    if (!((CurrentObject is IfcElement) && (CurrentObject.Name == row.RowName)))
                    {
                        CurrentObject = IfcElements.Where(b => b.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                    }
                    break;

                case "zone":
                    if (IfcZones == null)
                    {
                        IfcZones = Model.Instances.OfType <IfcZone>();
                    }
                    if (!((CurrentObject is IfcZone) && (CurrentObject.Name == row.RowName)))
                    {
                        CurrentObject = IfcZones.Where(b => b.Name.ToString().ToLower() == row.RowName.ToLower()).FirstOrDefault();
                    }
                    break;

                default:
                    CurrentObject = null;
                    break;
                }

                if (CurrentObject != null)
                {
                    if (ValidateString(row.Name))
                    {
                        IfcPropertySet ifcPropertySet = CheckIfExistOnMerge(row.ExtObject, row.ExtIdentifier);

                        if (ifcPropertySet == null)
                        {
                            return;
                        }

                        //Set Description
                        string description = "";
                        if (ValidateString(row.Description))
                        {
                            description = row.Description;
                        }


                        if ((ValidateString(row.Value)) &&
                            row.Value.Contains(":") &&
                            row.Value.Contains("(") &&
                            row.Value.Contains(")")
                            )//only if we have a IfcPropertyTableValue defined by COBieDataAttributeBuilder
                        {
                            AddPropertyTableValue(ifcPropertySet, row.Name, description, row.Value, row.AllowedValues, row.Unit);
                        }
                        else if ((ValidateString(row.AllowedValues)) &&
                                 //row.Value.Contains(":") && can be single value
                                 (row.AllowedValues.Contains(":") ||
                                  row.AllowedValues.Contains(",")
                                 )
                                 )//have a IfcPropertyEnumeratedValue
                        {
                            IfcValue[] ifcValues     = GetValueArray(row.Value);
                            IfcValue[] ifcValueEnums = GetValueArray(row.AllowedValues);
                            IfcUnit    ifcUnit       = GetIfcUnit(row.Unit);
                            AddPropertyEnumeratedValue(ifcPropertySet, row.Name, description, ifcValues, ifcValueEnums, ifcUnit);
                        }
                        else
                        {
                            IfcValue ifcValue;
                            double   number;
                            if (double.TryParse(row.Value, out number))
                            {
                                ifcValue = new IfcReal((double)number);
                            }
                            else if (ValidateString(row.Value))
                            {
                                ifcValue = new IfcLabel(row.Value);
                            }
                            else
                            {
                                ifcValue = new IfcLabel("");
                            }
                            IfcUnit ifcUnit = GetIfcUnit(row.Unit);
                            AddPropertySingleValue(ifcPropertySet, row.Name, description, ifcValue, ifcUnit);
                        }

                        //Add Category****
                        if (ValidateString(row.Category))
                        {
                            SetCategory(ifcPropertySet, row.Category);
                        }

                        //****************Note need this as last call Add OwnerHistory*************
                        if (ifcPropertySet != null)
                        {
                            //Add Created By, Created On and ExtSystem to Owner History.
                            SetUserHistory(ifcPropertySet, row.ExtSystem, row.CreatedBy, row.CreatedOn);
                        }
                        //****************Note need SetOwnerHistory above to be last call, as XBim changes to default on any property set or changed, cannot use edit context as property set used more than once per row******
                    }
                    else
                    {
 #if DEBUG
                        Console.WriteLine("Failed to create attribute. No name : {0} value {1}", row.Name, row.ExtObject);
#endif
                    }
                }
                else
                {
#if DEBUG
                    Console.WriteLine("Failed to create attribute. No object found to add too {0} value {1}", row.Name, row.ExtObject);
#endif
                }
            }
            else
            {
#if DEBUG
                Console.WriteLine("Failed to create attribute. No sheet or row name {0} value {1}", row.Name, row.ExtObject);
#endif
            }
        }
Example #5
0
        /// <summary>
        /// Add the object the document relates too
        /// </summary>
        /// <param name="row">COBieDocumentRow holding row data</param>
        private IfcRoot GetObjectRelationship(COBieDocumentRow row)
        {
            IfcRoot ifcRoot = null;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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