Beispiel #1
0
        public AttributeType[] GetAttributes(IfcObjectDefinition ifcObjectDefinition)
        {
            XbimAttributedObject attributedObject;

            if (_attributedObjects.TryGetValue(ifcObjectDefinition, out attributedObject))
            {
                var properties    = attributedObject.Properties.Where(kv => !_cobieProperties.Contains(kv.Key)); //exclude the properties we have written as COBie value
                var keyValuePairs = properties as KeyValuePair <string, IfcProperty>[] ?? properties.ToArray();
                if (keyValuePairs.Length > 0)
                {
                    var attributeCollection = new AttributeType[keyValuePairs.Length];
                    for (int i = 0; i < keyValuePairs.Length; i++)
                    {
                        var property      = keyValuePairs[i].Value;
                        var splitName     = keyValuePairs[i].Key.Split('.');
                        var pSetName      = splitName[0];
                        var attributeType = XbimAttributedObject.ConvertToAttributeType(property);
                        attributeType.propertySetName = pSetName;
                        //var pSetDef = attributedObject.GetPropertySetDefinition(pSetName);
                        //if (pSetDef != null)
                        //    attributeType.externalID = ExternalEntityIdentity(pSetDef);
                        attributeCollection[i] = attributeType;
                    }
                    return(attributeCollection);
                }
            }
            return(null);
        }
        /// <summary>
        /// Set the property sets mapped to list of simple property values held for the IfcTypeObject
        /// filtered by a IfcPropertySet name
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject holding the property values</param>
        /// <param name="propertySetNames">List of IfcPropertySetName</param>
        public void SetAllPropertyValues(IfcTypeObject ifcTypeObject, List <string> propertySetNames)
        {
            _currentObject = ifcTypeObject;
            PSetFilterOn   = true;

            if (ifcTypeObject.HasPropertySets != null) //we have properties to get
            {
                _mapPsetToProps = ifcTypeObject.HasPropertySets.OfType <IfcPropertySet>()
                                  .Where(ps => (propertySetNames.Contains(ps.Name)))
                                  .ToDictionary(ps => ps, ps => ps.HasProperties.OfType <IfcSimpleProperty>());
            }
            else
            {
                _mapPsetToProps.Clear(); //clear as we have no properties for this object
            }

            //fall back to related items to get the information from
            if (!_mapPsetToProps.Any())//not sure we should do this, but we get values to fill from an object that is using the type object
            {
                if (ifcTypeObject.ObjectTypeOf.Any())
                {
                    IfcObject IfcObj = ifcTypeObject.ObjectTypeOf.First().RelatedObjects.FirstOrDefault();
                    if (IfcObj != null)
                    {
                        SetAllPropertyValues(IfcObj); //we do not filter on property set name here, just go for all of them
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// These units are used for specification of the new properties. Existing properties are not affected.
        /// </summary>
        public static void SetMetersAndMilimetersAsBaseUnit(IfcObjectDefinition ifcObject)
        {
            IModel model = ifcObject.ModelOf;

            if (_lengthUnit == null || !(_lengthUnit is IfcSIUnit)) 
            {
                //length unit
                IfcSIUnit lengthUnit = model.Instances.New<IfcSIUnit>();
                lengthUnit.Name = IfcSIUnitName.METRE;
                lengthUnit.Prefix = IfcSIPrefix.MILLI;
                lengthUnit.UnitType = IfcUnitEnum.LENGTHUNIT;
                _lengthUnit = lengthUnit;
            }

            if (_areaUnit == null ||!(_areaUnit is IfcSIUnit))
            {
                //area unit
                IfcSIUnit areaUnit = model.Instances.New<IfcSIUnit>();
                areaUnit.Name = IfcSIUnitName.SQUARE_METRE;
                areaUnit.UnitType = IfcUnitEnum.AREAUNIT;
                _areaUnit = areaUnit;
            }

            if (_volumeUnit == null || !(_volumeUnit is IfcSIUnit))
            {
                //volume init
                IfcSIUnit volumeUnit = model.Instances.New<IfcSIUnit>();
                volumeUnit.Name = IfcSIUnitName.CUBIC_METRE;
                volumeUnit.UnitType = IfcUnitEnum.VOLUMEUNIT;
                _volumeUnit = volumeUnit;
            }
        }
Beispiel #4
0
        public string GetCoBieProperty(string valueName, IfcObjectDefinition ifcObjectDefinition)
        {
            XbimAttributedObject attributedObject;

            if (_attributedObjects.TryGetValue(ifcObjectDefinition, out attributedObject))
            {
                string[] propertyNames;
                if (_cobieFieldMap.TryGetValue(valueName, out propertyNames))
                {
                    foreach (var propertyName in propertyNames)
                    {
                        string value;
                        if (attributedObject.GetSimplePropertyValue(propertyName, out value))
                        {
                            return(value);
                        }
                    }
                }
                else
                {
                    throw new ArgumentException("Illegal COBie Attribute name:", valueName);
                }
            }
            return(null);
        }
Beispiel #5
0
        //TODO: Check function below, see if it works!
        /// <summary>
        /// Test for IfcObjectDefinition exists in IfcToExclude type lists
        /// </summary>
        /// <param name="obj">IfcObjectDefinition object</param>
        /// <returns>bool, true = exclude</returns>
        public bool ItemsFilter(IfcObjectDefinition obj)
        {
            if (ItemsToExclude.Count == 0)
            {
                return(false);                           //nothing to test against
            }
            var  objType   = obj.GetType();
            var  objString = objType.Name.ToUpper(); //obj.ToString().ToUpper(); //or this might work, obj.IfcType().IfcTypeEnum.ToString();
            bool result    = ItemsToExclude.Contains(objString);

            if (!result && (PreDefinedType.ContainsKey(objString)))
            {
                var objPreDefinedProp = objType.GetProperty("PredefinedType");

                if (objPreDefinedProp != null)
                {
                    var objPreDefValue = objPreDefinedProp.GetValue(obj, null);

                    if (objPreDefValue != null)
                    {
                        var preDefType = objPreDefValue.ToString();
                        if (!string.IsNullOrEmpty(preDefType))
                        {
                            result = !PreDefinedType[objString].Contains(preDefType.ToUpper());
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #6
0
        private bool IsContinuedAssemblyRow(COBieAssemblyRow row)
        {
            if (ValidateString(row.Name))
            {
                if (row.Name.Contains(" : continued "))         //our flag for a continued assembly child list
                {
                    return(true);
                }

                if (ValidateString(row.ChildNames))
                {
                    string name     = row.Name.ToLower().Trim();
                    string lastname = LastRow.Name.ToLower().Trim();
                    lastname = RemPostFixNumber(lastname);

                    if (name.Contains(lastname))
                    {
                        //this is a bit messy but gets over the placement of : on single entries
                        IEnumerable <IfcObjectDefinition> childObjs = GetSheetObjectList(row.SheetName);
                        //check that the name is not a single element, also gets over single entries with : in them
                        string test = row.ChildNames.ToLower().Trim();
                        IfcObjectDefinition RelatedObject = childObjs.Where(obj => obj.Name.ToString().ToLower().Trim() == test).FirstOrDefault();
                        if (RelatedObject != null)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #7
0
        public static void AddObjectToGroup(this IfcGroup gr, IfcObjectDefinition obj)
        {
            IModel model = gr.Model;

            IfcRelAssignsToGroup relation = gr.IsGroupedBy ?? model.Instances.New <IfcRelAssignsToGroup>(rel => rel.RelatingGroup = gr);

            relation.RelatedObjects.Add(obj);
        }
        internal void ConvertAttributeTypeToIfcObjectProperty(IfcObjectDefinition ifcObjectDefinition, AttributeType attributeType)
        {
            //need to add in consideration for quantities not just properties
            var ifcSimpleProperty = ConvertAttributeTypeToIfcSimpleProperty(attributeType);
            var propertySet       = GetOrCreatePropertySetDefinition(ifcObjectDefinition, attributeType.propertySetName);

            propertySet.Add(ifcSimpleProperty);
        }
Beispiel #9
0
        /*public IfcPropertySet AddPropertySet(IfcBuildingElementProxy element, List<IfcProperty> properties){
         *      var ps = new IfcPropertySet(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()),properties);
         *      var def = new IfcPropertySetDefinition(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()));
         *      var test = new IfcPropertySetDefinitionSelect();
         *      //var r = new IfcRelDefinesByProperties(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()), new List<IfcObjectDefinition>{element},);
         * }*/

        private void CreateAggregationRelationship(IfcObjectDefinition from, IfcObjectDefinition to)
        {
            var r = new IfcRelAggregates(IfcGuid.IfcGuid.ToIfcGuid(Guid.NewGuid()), from, new List <IfcObjectDefinition> {
                to
            });

            from.Decomposes.Add(r);
            storage.AddInstance(r);
        }
        public static void AddDecomposingObjectToFirstAggregation(this IfcObjectDefinition obj, IModel model,
                                                                  IfcObjectDefinition decomposingObject)
        {
            IfcRelAggregates rel =
                model.Instances.Where <IfcRelAggregates>(r => r.RelatingObject == obj).FirstOrDefault() ??
                model.Instances.New <IfcRelAggregates>(r => r.RelatingObject = obj);

            rel.RelatedObjects.Add(decomposingObject);
        }
        /// <summary>
        /// Set the property sets mapped to list of simple property values held for the IfcObject
        /// </summary>
        /// <param name="ifcObject">IfcObject holding the property values</param>
        public void SetAllPropertyValues(IfcObject ifcObject)
        {
            _currentObject = ifcObject;
            PSetFilterOn   = false;

            _mapPsetToProps = ifcObject.IsDefinedByProperties
                              .Select(def => def.RelatingPropertyDefinition).OfType <IfcPropertySet>()
                              .ToDictionary(ps => ps, ps => ps.HasProperties.OfType <IfcSimpleProperty>());
        }
        public static void AddDecomposingObjectToFirstAggregation(this IfcObjectDefinition obj, IModel model,
                                                                  IfcObjectDefinition decomposingObject)
        {
            IfcRelAggregates rel =
                model.InstancesWhere<IfcRelAggregates>(r => r.RelatingObject == obj).FirstOrDefault() ??
                model.New<IfcRelAggregates>(r => r.RelatingObject = obj);

            rel.RelatedObjects.Add_Reversible(decomposingObject);
        }
Beispiel #13
0
        /// <summary>
        /// Add the parent objects to the IfcRelDecomposes
        /// </summary>
        /// <param name="ifcRelDecomposes">Either a IfcRelAggregates or IfcRelNests object</param>
        /// <param name="parentName">IfcObjectDefinition.Name value to search for, NOT case sensitive</param>
        /// <returns></returns>
        private bool AddParentObject(IfcRelDecomposes ifcRelDecomposes, string parentName)
        {
            IfcObjectDefinition relatingObject = GetParentObject(parentName);

            if (relatingObject != null)
            {
                ifcRelDecomposes.RelatingObject = relatingObject;
                return(true);
            }
            return(false);
        }
Beispiel #14
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);
        }
Beispiel #15
0
        public static IfcRelAggregates NewIfc4Decomposes(this IModel s, IfcObjectDefinition host)
        {
            var relation = host.IsDecomposedBy.FirstOrDefault();

            if (null == relation)
            {
                relation = s.Instances.New <IfcRelAggregates>();
            }

            relation.RelatingObject = host;
            return(relation);
        }
Beispiel #16
0
        public static void AddObjectToGroup(this IfcGroup gr, IfcObjectDefinition obj)
        {
            IModel model = GetModel(gr);

            IfcRelAssignsToGroup relation = gr.IsGroupedBy;

            if (gr.IsGroupedBy == null)
            {
                relation = model.Instances.New <IfcRelAssignsToGroup>(rel => rel.RelatingGroup = gr);
            }
            relation.RelatedObjects.Add(obj);
        }
        public static IfcMaterialSelect GetMaterial(this IfcObjectDefinition objDef)
        {
            IfcRelAssociatesMaterial relMat = objDef.HasAssociations.OfType <IfcRelAssociatesMaterial>().FirstOrDefault();

            if (relMat != null)
            {
                return(relMat.RelatingMaterial);
            }
            else
            {
                return(null);
            }
        }
Beispiel #18
0
        internal void checkProperty(IfcObjectDefinition obj, string psetName, string propertyName, bool permitType, HashSet <String> allowableStrings)
        {
            IfcPropertySingleValue propertySingleValue = null;

            if (!string.IsNullOrEmpty(psetName))
            {
                IfcPropertySet propertySet = null;
                if (obj is IfcObject ifcObject)
                {
                    propertySet = ifcObject.FindPropertySet(psetName, permitType) as IfcPropertySet;
                }
                else
                {
                    propertySet = obj.FindPropertySet(psetName) as IfcPropertySet;
                }
                if (propertySet == null)
                {
                    System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " missing pset " + psetName);
                    return;
                }
                propertySingleValue = propertySet.FindProperty(propertyName) as IfcPropertySingleValue;
            }
            else
            {
                propertySingleValue = obj.FindProperty(propertyName) as IfcPropertySingleValue;
            }
            if (propertySingleValue == null)
            {
                System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " missing property " + propertyName);
                return;
            }
            if (propertySingleValue.NominalValue == null)
            {
                System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " property " + propertyName + " has no value!");
                return;
            }
            if (allowableStrings.Count > 0)
            {
                string propertyValue = propertySingleValue.NominalValue.ValueString;
                if (!allowableStrings.Contains(propertyValue))
                {
                    System.Diagnostics.Debug.WriteLine("Test Fail " + obj.GlobalId + " " + obj.Name + " property " + propertyName + " has unacceptable value :" + propertyValue);
                    return;
                }
            }
        }
Beispiel #19
0
        public static bool RemoveObjectFromGroup(this IfcGroup gr, IfcObjectDefinition obj)
        {
            if (gr == null || obj == null)
            {
                return(false);
            }
            IModel model = GetModel(gr);
            IfcRelAssignsToGroup relation = gr.IsGroupedBy;

            if (gr.IsGroupedBy == null)
            {
                return(false);
            }
            if (!relation.RelatedObjects.Contains(obj))
            {
                return(false);
            }
            relation.RelatedObjects.Remove(obj);
            return(true);
        }
 /// <summary>
 ///   Adds a Related object if it's type obeys the constraint set by RelatedObjectType or no constraint has been set
 /// </summary>
 public bool AddRelatedObject(IfcObjectDefinition obj)
 {
     if (_relatedObjectsType.HasValue == false) //you can add it, no contraints applied
     {
         _relatedObjects.Add(obj);
         return true;
     }
     bool addIt = false;
     switch (_relatedObjectsType.Value)
     {
         case IfcObjectType.Product:
             addIt = (obj is IfcProduct);
             break;
         case IfcObjectType.Process:
             addIt = (obj is IfcProcess);
             break;
         case IfcObjectType.Control:
             addIt = (obj is IfcControl);
             break;
         case IfcObjectType.Resource:
             addIt = (obj is IfcResource);
             break;
         case IfcObjectType.Actor:
             addIt = (obj is IfcActor);
             break;
         case IfcObjectType.Group:
             addIt = (obj is IfcGroup);
             break;
         case IfcObjectType.Project:
             addIt = (obj is IfcProject);
             break;
         case IfcObjectType.NotDefined:
             addIt = true;
             break;
         default: //invalid constraint so add it
             addIt = true;
             break;
     }
     if (addIt) _relatedObjects.Add(obj);
     return addIt;
 }
Beispiel #21
0
        /// <summary>
        /// Add the child objects to the IfcRelDecomposes
        /// </summary>
        /// <param name="ifcRelDecomposes">Either a IfcRelAggregates or IfcRelNests object</param>
        /// <param name="sheetName">SheetName the children come from</param>
        /// <param name="childNames">list of child object names separated by " : ", NOT case sensitive</param>
        private bool AddChildObjects(IfcRelDecomposes ifcRelDecomposes, string sheetName, string childNames)
        {
            bool returnValue = false;
            IEnumerable <IfcObjectDefinition> childObjs = GetSheetObjectList(sheetName);
            //check that the name is not a single element, also gets over single entries with : in them
            string test = childNames.ToLower().Trim();
            IfcObjectDefinition RelatedObject = childObjs.Where(obj => obj.Name.ToString().ToLower().Trim() == test).FirstOrDefault();

            if (RelatedObject != null)
            {
                //check we have not already added as this can be a merge
                if (!ifcRelDecomposes.RelatedObjects.Contains(RelatedObject))
                {
                    ifcRelDecomposes.RelatedObjects.Add(RelatedObject);
                }
                returnValue = true;
            }
            else //ok nothing found for the full string so assume delimited string
            {
                char          splitChar       = GetSplitChar(childNames);
                List <string> splitChildNames = SplitString(childNames, splitChar);

                foreach (string item in splitChildNames)
                {
                    string name = item.ToLower().Trim();
                    RelatedObject = childObjs.Where(obj => obj.Name.ToString().ToLower().Trim() == name).FirstOrDefault();
                    if (RelatedObject != null)
                    {
                        //check we have not already added as this can be a merge
                        if (!ifcRelDecomposes.RelatedObjects.Contains(RelatedObject))
                        {
                            ifcRelDecomposes.RelatedObjects.Add(RelatedObject);
                        }
                        returnValue = true;
                    }
                }
            }
            return(returnValue);
        }
Beispiel #22
0
        //TODO: Check function below, see if it works!
        /// <summary>
        /// filter on IfcObjectDefinition objects
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>bool true = exclude</returns>
        public bool ObjFilter(IfcObjectDefinition obj, bool checkType = true)
        {
            bool exclude = false;

            if (obj is IfcProduct)
            {
                exclude = IfcProductFilter.ItemsFilter(obj);
                //check the element is not defined by a type which is excluded, by default if no type, then no element included
                if (!exclude && checkType)
                {
                    IfcTypeObject objType = ((IfcProduct)obj).IsDefinedBy.OfType <IfcRelDefinesByType>().Select(rdbt => rdbt.RelatingType).FirstOrDefault(); //assuming only one IfcRelDefinesByType
                    if (objType != null)                                                                                                                     //if no type defined lets include it for now
                    {
                        exclude = IfcTypeObjectFilter.ItemsFilter(objType);
                    }
                }
            }
            else if (obj is IfcTypeProduct)
            {
                exclude = IfcTypeObjectFilter.ItemsFilter(obj);
            }
            return(FlipResult ? !exclude : exclude);
        }
Beispiel #23
0
            public PropertyHashedObjectDefinition(IfcObjectDefinition objDef)
            {
                _objDef = objDef;
                IEnumerable <IfcPropertySet> pSets = null;
                var o = objDef as IfcObject;

                if (o != null)
                {
                    pSets = o.GetAllPropertySets();
                }
                var t = objDef as IfcTypeObject;

                if (t != null)
                {
                    pSets = t.GetAllPropertySets();
                }

                _hash = 0;
                foreach (var pSet in pSets)
                {
                    _hash += pSet.GetPSetHash();
                }
            }
            public static void ExtractTypicalProperties(IfcObjectDefinition ifcele, Core Model)
            {
                Model.IfcId = ifcele.Guid;
                Model.Name  = ifcele.Name;

                try
                {
                    //get element ID
                    Model.ElementId = int.Parse(((IfcElement)ifcele).Tag);
                }
                catch (Exception)
                {
                    try
                    {
                        Model.ElementId = int.Parse(((IfcWallType)ifcele).Tag);
                    }
                    catch (Exception)
                    {
                        //object doesn't have Tag Property
                        Debug.WriteLine(ifcele.Name + "Doesn't have Tag Property\r\n" + ifcele.StringSTEP());
                    }
                }
            }
Beispiel #25
0
        public static T NewIfc4Product <T>(this IModel s, IfcObjectDefinition container = null, string name = null) where T : IInstantiableEntity, IIfcProduct
        {
            var product = s.Instances.New <T>(p => p.Name = name);

            if (container is IfcSpatialElement e)
            {
                if (product is IfcSpatialElement)
                {
                    // Spatial-in-spatial substructure
                    s.NewIfc4Decomposes(e).RelatedObjects.Add(product as IfcProduct);
                }
                else
                {
                    // Product containment
                    s.NewIfc4Contains(e).RelatedElements.Add(product as IfcProduct);
                }
            }
            else
            {
                s.NewIfc4Decomposes(container).RelatedObjects.Add(product as IfcProduct);
            }

            return(product);
        }
Beispiel #26
0
        //TODO: Check function below, see if it works!
        /// <summary>
        /// Test for IfcObjectDefinition exists in IfcToExclude type lists
        /// </summary>
        /// <param name="obj">IfcObjectDefinition object</param>
        /// <returns>bool, true = exclude</returns>
        public bool ItemsFilter(IfcObjectDefinition obj)
        {
            if (ItemsToExclude.Count == 0) return false; //nothing to test against

            var objType = obj.GetType();
            var objString = objType.Name.ToUpper(); //obj.ToString().ToUpper(); //or this might work, obj.IfcType().IfcTypeEnum.ToString();
            bool result = ItemsToExclude.Contains(objString);
            
            if (!result && (PreDefinedType.ContainsKey(objString)))
            {
                var objPreDefinedProp = objType.GetProperty("PredefinedType");
            
                if (objPreDefinedProp != null)
                {

                    var objPreDefValue = objPreDefinedProp.GetValue(obj,null);

                    if (objPreDefValue != null)
                    {
                        var preDefType = objPreDefValue.ToString();
                        if (!string.IsNullOrEmpty(preDefType))
                        {
                            result = !PreDefinedType[objString].Contains(preDefType.ToUpper());
                        } 
                    }
                }
            }
            return result;
        }
        internal IfcPropertySetDefinition GetOrCreatePropertySetDefinition(IfcObjectDefinition ifcObjectDefinition, string propertySetName)
        {
            List <IfcPropertySetDefinition> propertySetDefinitionList;

            if (!_objectsToPropertySets.TryGetValue(ifcObjectDefinition, out propertySetDefinitionList))
            {
                propertySetDefinitionList = new List <IfcPropertySetDefinition>();
                _objectsToPropertySets.Add(ifcObjectDefinition, propertySetDefinitionList);
            }
            var propertySet = propertySetDefinitionList.Find(p => p.Name == propertySetName);

            if (propertySet == null)
            {
                //simplistic way to decide if this should be a quantity, IFC 4 specifies the name starts with QTO, under 2x3 most vendors have gone for BaseQuantities
                if (propertySetName != null && (propertySetName.StartsWith("qto_", true, CultureInfo.InvariantCulture) ||
                                                propertySetName.StartsWith("basequantities", true,
                                                                           CultureInfo.InvariantCulture)))
                {
                    var quantitySet = TargetRepository.Instances.New <IfcElementQuantity>();
                    propertySetDefinitionList.Add(quantitySet);
                    quantitySet.Name = propertySetName;
                    var ifcObject     = ifcObjectDefinition as IfcObject;
                    var ifcTypeObject = ifcObjectDefinition as IfcTypeObject;
                    if (ifcObject != null)
                    {
                        var relDef = TargetRepository.Instances.New <IfcRelDefinesByProperties>();
                        relDef.RelatingPropertyDefinition = quantitySet;
                        relDef.RelatedObjects.Add(ifcObject);
                    }
                    else if (ifcTypeObject != null)
                    {
                        if (ifcTypeObject.HasPropertySets == null)
                        {
                            ifcTypeObject.CreateHasPropertySets();
                        }
                        ifcTypeObject.HasPropertySets.Add(quantitySet);
                    }
                    else
                    {
                        throw new Exception("Invalid object type " + ifcObjectDefinition.GetType().Name);
                    }

                    propertySet = quantitySet;
                }
                else //it is a normal property set
                {
                    propertySet = TargetRepository.Instances.New <IfcPropertySet>();
                    propertySetDefinitionList.Add(propertySet);
                    propertySet.Name = propertySetName;
                    var ifcObject     = ifcObjectDefinition as IfcObject;
                    var ifcTypeObject = ifcObjectDefinition as IfcTypeObject;
                    if (ifcObject != null)
                    {
                        var relDef = TargetRepository.Instances.New <IfcRelDefinesByProperties>();
                        relDef.RelatingPropertyDefinition = propertySet;
                        relDef.RelatedObjects.Add(ifcObject);
                    }
                    else if (ifcTypeObject != null)
                    {
                        if (ifcTypeObject.HasPropertySets == null)
                        {
                            ifcTypeObject.CreateHasPropertySets();
                        }
                        ifcTypeObject.HasPropertySets.Add(propertySet);
                    }
                    else
                    {
                        throw new Exception("Invalid object type " + ifcObjectDefinition.GetType().Name);
                    }
                }
            }
            return(propertySet);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="obj"></param>
 public XbimAttributedObject(IfcObjectDefinition obj)
 {
     _ifcObject = obj;
 }
        /// <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
            }
            
        }
 public COBieXBimAttribute(COBieXBimContext xBimContext)
     : base(xBimContext)
 {
     CurrentObject = null;
     
 }
 public override void IfcParse(int propIndex, IPropertyValue value)
 {
     switch (propIndex)
     {
         case 0:
             base.IfcParse(propIndex, value);
             break;
         case 1:
             base.IfcParse(propIndex, value);
             break;
         case 2:
             base.IfcParse(propIndex, value);
             break;
         case 3:
             base.IfcParse(propIndex, value);
             break;
         case 4:
             _relatingObject = (IfcObjectDefinition) value.EntityVal;
             break;
         case 5:
             _relatedObjects.Add((IfcObjectDefinition) value.EntityVal);
             break;
         default:
             this.HandleUnexpectedAttribute(propIndex, value); break;
     }
 }
Beispiel #32
0
        internal bool isClassified(string classificationId, string classificationName, IfcObjectDefinition obj)
        {
            List <IfcRelAssociatesClassification> references = obj.HasAssociations.OfType <IfcRelAssociatesClassification>().ToList();

            if (obj is IfcObject ifcObject)
            {
                IfcTypeObject typeObject = ifcObject.RelatingType();
                if (typeObject != null)
                {
                    references.AddRange(typeObject.HasAssociations.OfType <IfcRelAssociatesClassification>());
                }
            }

            foreach (IfcClassificationReference classificationReference in references.Select(x => x.RelatingClassification).OfType <IfcClassificationReference>())
            {
                if (string.Compare(classificationId, classificationReference.Identification, true) == 0)
                {
                    if (string.IsNullOrEmpty(classificationName))
                    {
                        return(true);
                    }
                    IfcClassification classification = classificationReference.ReferencedClassification();
                    if (classification != null && string.Compare(classification.Name, classificationName, true) == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// Set the property sets mapped to list of simple property values held for the IfcTypeObject
        /// filtered by a IfcPropertySet name
        /// </summary>
        /// <param name="ifcTypeObject">IfcTypeObject holding the property values</param>
        /// <param name="propertySetNames">List of IfcPropertySetName</param>
        public void SetAllPropertyValues(IfcTypeObject ifcTypeObject, List<string> propertySetNames)
        {
            _currentObject = ifcTypeObject;
            PSetFilterOn = true;

            if (ifcTypeObject.HasPropertySets != null) //we have properties to get
            {
                _mapPsetToProps = ifcTypeObject.HasPropertySets.OfType<IfcPropertySet>()
                                .Where(ps => (propertySetNames.Contains(ps.Name)))
                                .ToDictionary(ps => ps, ps => ps.HasProperties.OfType<IfcSimpleProperty>());
            }
            else
            {
                _mapPsetToProps.Clear(); //clear as we have no properties for this object
            }

            //fall back to related items to get the information from
            if (!_mapPsetToProps.Any())//not sure we should do this, but we get values to fill from an object that is using the type object
            {
                if (ifcTypeObject.ObjectTypeOf.Any())
                {
                    IfcObject IfcObj = ifcTypeObject.ObjectTypeOf.First().RelatedObjects.FirstOrDefault();
                    if (IfcObj != null)
                    {
                        SetAllPropertyValues(IfcObj); //we do not filter on property set name here, just go for all of them
                    }

                }

            }
        }
Beispiel #34
0
        public TCoBieValueBaseType GetCoBieAttribute <TCoBieValueBaseType>(string valueName, IfcObjectDefinition ifcObjectDefinition)
            where TCoBieValueBaseType : ValueBaseType, new()
        {
            XbimAttributedObject attributedObject;
            var result = new TCoBieValueBaseType();

            if (_attributedObjects.TryGetValue(ifcObjectDefinition, out attributedObject))
            {
                string[] propertyNames;
                if (_cobieFieldMap.TryGetValue(valueName, out propertyNames))
                {
                    foreach (var propertyName in propertyNames)
                    {
                        if (attributedObject.GetAttributeValue(propertyName, ref result))
                        {
                            return(result);
                        }
                    }
                }
                else
                {
                    throw new ArgumentException("Illegal COBie Attribute name:", valueName);
                }
            }
            return(result);
        }
        /// <summary>
        /// Set the property sets mapped to list of simple property values held for the IfcObject
        /// </summary>
        /// <param name="ifcObject">IfcObject holding the property values</param>
        public void SetAllPropertyValues (IfcObject ifcObject)
        {
            _currentObject = ifcObject;
            PSetFilterOn = false;

            _mapPsetToProps = ifcObject.IsDefinedByProperties
                            .Select(def => def.RelatingPropertyDefinition).OfType<IfcPropertySet>()
                            .ToDictionary(ps => ps, ps => ps.HasProperties.OfType<IfcSimpleProperty>());
        }
 public COBieXBimAttribute(COBieXBimContext xBimContext)
     : base(xBimContext)
 {
     CurrentObject = null;
 }
Beispiel #37
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;
            }
        }
Beispiel #38
0
        /// <summary>
        /// Get the category from the IfcRelAssociatesClassification / IfcClassificationReference objects
        /// </summary>
        /// <param name="obj">IfcObjectDefinition object</param>
        /// <returns></returns>
        public string GetCategoryClassification(IfcObjectDefinition obj)
        {
            //Try by relationship first
            var ifcRAC = obj.HasAssociations.OfType <IfcRelAssociatesClassification>().FirstOrDefault();
            IfcClassificationReference ifcCR = null;

            if (ifcRAC != null)
            {
                ifcCR = ifcRAC.RelatingClassification as IfcClassificationReference;
            }

            if (ifcCR != null)
            {
                var conCatChar = " : ";
                if ((Context.TemplateFileName != null) && (Context.TemplateFileName.Contains("COBie-US"))) //change for US format
                {
                    conCatChar = ": ";
                }
                //holders for first and last part of category
                string itemReference = ifcCR.ItemReference;
                if (!string.IsNullOrEmpty(itemReference))
                {
                    itemReference = itemReference.Trim();
                }

                string name = ifcCR.Name;
                if (!string.IsNullOrEmpty(name))
                {
                    name = name.Trim();
                }

                //need to use split as sometime the whole category is stored in both ItemReference and Name
                //We split here as sometimes the whole category(13-15 11 34 11: Office) is place in itemReference and Name
                if ((!string.IsNullOrEmpty(name)) &&
                    (!string.IsNullOrEmpty(itemReference))
                    )
                {
                    itemReference = itemReference.Split(':').First().Trim();
                    var nameSplit = name.Split(':');
                    //just in case we have more than one ":"in name
                    if (nameSplit.First().Trim().Equals(itemReference, StringComparison.OrdinalIgnoreCase))
                    {
                        for (var i = 0; i < nameSplit.Count(); i++)
                        {
                            //skip first item
                            if (i == 1)
                            {
                                name = nameSplit[i].Trim();
                            }
                            if (i > 1)
                            {
                                name += conCatChar + nameSplit[i].Trim();        //add back the second, third... ": "
                            }
                        }
                    }
                    else
                    {
                        name = nameSplit.Last().Trim();
                    }
                }

                //Return the Category
                if ((!string.IsNullOrEmpty(itemReference)) &&
                    (!string.IsNullOrEmpty(name)) &&
                    (!itemReference.Equals(name, StringComparison.OrdinalIgnoreCase))
                    )
                {
                    return(itemReference + conCatChar + name);
                }
                else if (!string.IsNullOrEmpty(itemReference))
                {
                    return(itemReference);
                }
                else if (!string.IsNullOrEmpty(name))
                {
                    return(name);
                }
                else if (!string.IsNullOrEmpty(ifcCR.Location))
                {
                    return(ifcCR.Location);
                }
                else if ((ifcCR.ReferencedSource != null) &&
                         (!string.IsNullOrEmpty(ifcCR.ReferencedSource.Name))
                         )
                {
                    return(ifcCR.ReferencedSource.Name);
                }
            }
            return(null);
        }
        /// <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
            }
        }