public TValue GetCoBieProperty <TValue>(string valueName, IfcObject ifcObject) where TValue : struct { XbimAttributedObject attributedObject; if (_attributedObjects.TryGetValue(ifcObject, out attributedObject)) { string[] propertyNames; if (_cobieFieldMap.TryGetValue(valueName, out propertyNames)) { foreach (var propertyName in propertyNames) { TValue value; if (attributedObject.GetSimplePropertyValue(propertyName, out value)) { return(value); } } } else { throw new ArgumentException("Illegal COBie Attribute name:", valueName); } } return(default(TValue)); }
public void SampleChildren(IfcObject objIfc, Action <List <string> > collectionSampler) { List <IfcRelDecomposes> decomposed = objIfc.IsDecomposedBy.ToList(); if (decomposed == null || decomposed.Count == 0) { return; } List <string> collection = new List <string> { objIfc.GetType().Name }; foreach (var dec in decomposed) { foreach (var obj in dec.RelatedObjects) { collection.Add(obj.GetType().Name); if (typeof(IfcSpatialStructureElement).IsAssignableFrom(obj.GetType())) { SampleSpatialStructure((IfcSpatialStructureElement)obj, collectionSampler); } else { //do nothing ? actually, later try to figure out what these objs are } } } collectionSampler.Invoke(collection); }
/// <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 } } } }
/// <summary> /// Set values for attribute sheet /// </summary> /// <param name="ifcObject">ifcObject to extract properties from</param> /// <param name="_attributes">The attribute Sheet to add the properties to its rows</param> public void PopulateAttributesRows(IfcObject ifcObject) { if (PropertSetValues.PSetFilterOn) //we have a property set filter set in the PropertSetValues class, so reset to retrieve all property sets for this object { PropertSetValues.SetAllPropertyValues(ifcObject); } foreach (KeyValuePair <IfcPropertySet, IEnumerable <IfcSimpleProperty> > pairValues in PropertSetValues.MapPsetToProps) { IfcPropertySet ps = pairValues.Key; //get Property Set //check property set exclude list if (!string.IsNullOrEmpty(ps.Name)) { if (ExcludeAttributePropertySetNames.Count() > 0) { if (ExcludeAttributePropertySetNames.Contains(ps.Name)) { continue; //skip this loop iteration if property set name matches exclude list item } } } //Get Property SetAttribSheet Property Single Values IEnumerable <IfcSimpleProperty> pSVs = pairValues.Value; //filter on ExcludePropertyValueNames and ExcludePropertyValueNamesWildcard pSVs = FilterRows(pSVs); //fill in the data to the attribute rows ProcessAttributeRow(ps, pSVs); } }
private IEnumerable <IPersistIfcEntity> FilterElementsByType(IEnumerable <IPersistIfcEntity> elements, IEnumerable <IPersistIfcEntity> types) { //create lists from input arguments because enumeration crashes otherwise List <IPersistIfcEntity> elemList = elements.ToList(); List <IPersistIfcEntity> typeList = types.ToList(); foreach (var element in elemList) { IfcObject obj = element as IfcObject; if (obj != null) { IfcTypeObject defType = obj.GetDefiningType(); if (defType != null) { if (typeList.Contains(defType)) { yield return(element); } } else { yield return(element); } } } }
internal XbimMaterialQuantities(IfcTypeObject ifcTypeObject, XbimDocument document) { if (ifcTypeObject == null || document == null) throw new ArgumentNullException(); _typeObject = ifcTypeObject; _object = null; _document = document; }
public static void SetElementPhysicalSimpleQuantity(this IfcObject elem, string qSetName, string qualityName, double value, XbimQuantityTypeEnum quantityType, IfcNamedUnit unit) { IModel model = elem.ModelOf; IfcElementQuantity qset = GetElementQuantity(elem, qSetName); if (qset == null) { qset = model.Instances.New <IfcElementQuantity>(); qset.Name = qSetName; IfcRelDefinesByProperties relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = qset; relDef.RelatedObjects.Add(elem); } //remove existing simple quality IfcPhysicalSimpleQuantity simpleQuality = GetElementPhysicalSimpleQuantity(elem, qSetName, qualityName); if (simpleQuality != null) { IfcElementQuantity elementQuality = GetElementQuantity(elem, qSetName); elementQuality.Quantities.Remove(simpleQuality); model.Delete(simpleQuality); } switch (quantityType) { case XbimQuantityTypeEnum.AREA: simpleQuality = model.Instances.New <IfcQuantityArea>(sq => sq.AreaValue = (IfcAreaMeasure)value); break; case XbimQuantityTypeEnum.COUNT: simpleQuality = model.Instances.New <IfcQuantityCount>(sq => sq.CountValue = (IfcCountMeasure)value); break; case XbimQuantityTypeEnum.LENGTH: simpleQuality = model.Instances.New <IfcQuantityLength>(sq => sq.LengthValue = (IfcLengthMeasure)value); break; case XbimQuantityTypeEnum.TIME: simpleQuality = model.Instances.New <IfcQuantityTime>(sq => sq.TimeValue = (IfcTimeMeasure)value); break; case XbimQuantityTypeEnum.VOLUME: simpleQuality = model.Instances.New <IfcQuantityVolume>(sq => sq.VolumeValue = (IfcVolumeMeasure)value); break; case XbimQuantityTypeEnum.WEIGHT: simpleQuality = model.Instances.New <IfcQuantityWeight>(sq => sq.WeightValue = (IfcMassMeasure)value); break; default: return; } simpleQuality.Unit = unit; simpleQuality.Name = qualityName; qset.Quantities.Add(simpleQuality); }
private void FillMaterialData() { if (_materials.Count > 0) { return; //don't fill unless empty } IfcObject ifcObj = _entity as IfcObject; if (ifcObj != null) { IEnumerable <IfcRelAssociatesMaterial> matRels = ifcObj.HasAssociations.OfType <IfcRelAssociatesMaterial>(); foreach (IfcRelAssociatesMaterial matRel in matRels) { // todo: bonghi: the following material items query is only temporary for debug purposes. // it shouldn't effect on Release because of lazy nature of yielded IEnumerables. // var v = Model.Instances.GetInstancesOfMaterial(matRel.RelatingMaterial, true); System.Diagnostics.Debug.WriteLine( string.Format("Items: {0}", string.Join(";", v.Select(x => x.EntityLabel).ToArray()) )); // end todo AddMaterialData(matRel.RelatingMaterial, ""); } } }
private static void extractPsetBase(IfcObject element, JsonIfcElement newElement, string logId = null) { if (element.IsDefinedBy != null && element.IsDefinedBy.Count > 0) { foreach (var psv in element.IsDefinedBy .OfType <IfcPropertySet>() .SelectMany(pset => pset.HasProperties .Select(tuple => tuple.Value) .OfType <IfcPropertySingleValue>())) { try { if (psv.Name != null && psv.NominalValue.ValueString != null && !newElement.userData.pset.ContainsKey(psv.Name)) { newElement.userData.pset.Add(psv.Name, psv.NominalValue.ValueString); } } catch (Exception e) { if (logId != null) { Console.WriteLine($"{logId}. Pset write error {e.Message}"); } } } } }
internal bool TryCreatePropertySingleValue(IfcObject ifcObject, string value, string cobiePropertyName) { try { NamedProperty namedProperty; if (CobieToIfcPropertyMap.TryGetValue(cobiePropertyName, out namedProperty)) { List <IfcPropertySetDefinition> propertySetDefinitionList; if (!_objectsToPropertySets.TryGetValue(ifcObject, out propertySetDefinitionList)) { propertySetDefinitionList = new List <IfcPropertySetDefinition>(); _objectsToPropertySets.Add(ifcObject, propertySetDefinitionList); } var propertySet = propertySetDefinitionList.Find(p => p.Name == namedProperty.PropertySetName) as IfcPropertySet; if (propertySet == null) { propertySet = TargetRepository.Instances.New <IfcPropertySet>(); propertySetDefinitionList.Add(propertySet); propertySet.Name = namedProperty.PropertySetName; var relDef = TargetRepository.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = propertySet; relDef.RelatedObjects.Add(ifcObject); } AddProperty(ifcObject, new IfcText(value), cobiePropertyName, propertySet, namedProperty); return(true); } throw new ArgumentException("Incorrect property map", "cobiePropertyName"); } catch (Exception e) { Debug.WriteLine("Incorrect property map, " + e.Message); Debug.Assert(false); } return(false); }
private IfcTypeObject GetDefiningTypeObject(IfcObject ifcObject) { IfcTypeObject definingType; _objectToTypeObjectMap.TryGetValue(ifcObject, out definingType); return(definingType); }
private void FillTypeData() { if (_typeProperties.Count > 0) { return; //don't fill unless empty } IfcObject ifcObj = _entity as IfcObject; if (ifcObj != null) { IfcTypeObject typeEntity = ifcObj.GetDefiningType(); if (typeEntity != null) { IfcType ifcType = IfcMetaData.IfcType(typeEntity); _typeProperties.Add(new PropertyItem() { Name = "Type", Value = ifcType.Type.Name }); _typeProperties.Add(new PropertyItem() { Name = "Ifc Label", Value = "#" + typeEntity.EntityLabel }); _typeProperties.Add(new PropertyItem() { Name = "Name", Value = typeEntity.Name }); _typeProperties.Add(new PropertyItem() { Name = "Description", Value = typeEntity.Description }); _typeProperties.Add(new PropertyItem() { Name = "GUID", Value = typeEntity.GlobalId }); _typeProperties.Add(new PropertyItem() { Name = "Ownership", Value = typeEntity.OwnerHistory.OwningUser.ToString() + " using " + typeEntity.OwnerHistory.OwningApplication.ApplicationIdentifier }); //now do properties in further specialisations that are text labels foreach (var pInfo in ifcType.IfcProperties.Where (p => p.Value.IfcAttribute.Order > 4 && p.Value.IfcAttribute.State != IfcAttributeState.DerivedOverride) ) //skip the first for of root, and derived and things that are objects { object val = pInfo.Value.PropertyInfo.GetValue(typeEntity, null); if (val != null && val is ExpressType) //only do express types { PropertyItem pi = new PropertyItem() { Name = pInfo.Value.PropertyInfo.Name, Value = ((ExpressType)val).ToPart21 }; _typeProperties.Add(pi); } } } } }
internal XbimQuantities(IfcTypeObject ifcTypeObject, string propertySetName) { if (ifcTypeObject == null || propertySetName == null || propertySetName == "") throw new ArgumentNullException(); _psetName = propertySetName; _ifcObject = null; _ifcTypeObject = ifcTypeObject ; SetMetersAndMilimetersAsBaseUnit(ifcTypeObject); }
/// <summary> /// Use this method to get all element quantities related to this object /// </summary> /// <returns>All related element quantities</returns> public static IEnumerable <IfcElementQuantity> GetAllElementQuantities(this IfcObject elem) { var rels = elem.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition is IfcElementQuantity); foreach (var rel in rels) { yield return(rel.RelatingPropertyDefinition as IfcElementQuantity); } }
/// <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>()); }
/// <summary> /// Adds an existing property set to the objecty, NB no check is done for duplicate psets /// </summary> /// <param name="obj"></param> /// <param name="pSet"></param> public static void AddPropertySet(this IfcObject obj, IfcPropertySet pSet) { IModel model = obj.ModelOf; IfcRelDefinesByProperties relDef = model.Instances.OfType <IfcRelDefinesByProperties>().Where(r => r.RelatingPropertyDefinition == pSet).FirstOrDefault();; if (relDef == null) { relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = pSet; } relDef.RelatedObjects.Add(obj); }
/// <summary> /// Returns simple physical quality of the element. /// </summary> /// <param name="elem"></param> /// <param name="pSetName"></param> /// <param name="qualityName"></param> /// <returns></returns> public static IfcPhysicalSimpleQuantity GetElementPhysicalSimpleQuantity(this IfcObject elem, string pSetName, string qualityName) { IfcElementQuantity elementQuality = GetElementQuantity(elem, pSetName); if (elementQuality != null) { return(elementQuality.Quantities.Where <IfcPhysicalSimpleQuantity>(sq => sq.Name == qualityName).FirstOrDefault()); } else { return(null); } }
public static void RemoveElementPhysicalSimpleQuantity(this IfcObject elem, string pSetName, string qualityName) { IfcElementQuantity elementQuality = GetElementQuantity(elem, pSetName); if (elementQuality != null) { IfcPhysicalSimpleQuantity simpleQuality = elementQuality.Quantities.Where <IfcPhysicalSimpleQuantity>(sq => sq.Name == qualityName).FirstOrDefault(); if (simpleQuality != null) { elementQuality.Quantities.Remove(simpleQuality); } } }
public static IfcTypeObject GetDefiningType(this IfcObject tObj) { IfcRelDefinesByType def = tObj.ModelOf.Instances.Where <IfcRelDefinesByType>(rd => rd.RelatedObjects.Contains(tObj)).FirstOrDefault(); if (def != null) { return(def.RelatingType); } else { return(null); } }
/// <summary> /// Get the related entity properties for the IfcTypeObject /// </summary> /// <param name="ifcTypeObject"> IfcTypeObject </param> /// <returns>Dictionary of IfcPropertySet keyed to List of IfcPropertySingleValue</returns> public Dictionary <IfcPropertySet, IEnumerable <IfcSimpleProperty> > GetRelatedProperties(IfcTypeObject ifcTypeObject) { if ((ifcTypeObject != null) && (ifcTypeObject.ObjectTypeOf.Any())) { IfcObject IfcObj = ifcTypeObject.ObjectTypeOf.First().RelatedObjects.FirstOrDefault(); if (IfcObj != null) { return(IfcObj.IsDefinedByProperties .Select(def => def.RelatingPropertyDefinition).OfType <IfcPropertySet>() .ToDictionary(ps => ps, ps => ps.HasProperties.OfType <IfcSimpleProperty>())); } } return(new Dictionary <IfcPropertySet, IEnumerable <IfcSimpleProperty> >()); }
/// <summary> /// Returns the first quantity that matches the quantity name /// </summary> /// <typeparam name="QType"></typeparam> /// <param name="elem"></param> /// <param name="qName"></param> /// <returns></returns> public static QType GetQuantity <QType>(this IfcObject elem, string qName) where QType : IfcPhysicalQuantity { IfcRelDefinesByProperties rel = elem.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition is IfcElementQuantity).FirstOrDefault(); if (rel != null) { IfcElementQuantity eQ = rel.RelatingPropertyDefinition as IfcElementQuantity; if (eQ != null) { QType result = eQ.Quantities.Where <QType>(q => q.Name == qName).FirstOrDefault(); return(result); } } return(default(QType)); }
public static IfcElementQuantity GetElementQuantity(this IfcObject elem, string pSetName, bool caseSensitive = true) { IfcRelDefinesByProperties rel = caseSensitive ? elem.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition.Name == pSetName && r.RelatingPropertyDefinition is IfcElementQuantity).FirstOrDefault() : elem.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition.Name.ToString().ToLower() == pSetName.ToLower() && r.RelatingPropertyDefinition is IfcElementQuantity).FirstOrDefault(); if (rel != null) { return(rel.RelatingPropertyDefinition as IfcElementQuantity); } else { return(null); } }
public JsonIfcObjectElement(IfcObject ifcElement) : base(ifcElement) { if (ifcElement.ObjectType != null) { userData.objectType = ifcElement.ObjectType; } if (ifcElement.Name != null) { userData.name = ifcElement.Name; } if (ifcElement.StepClassName != null) { userData.type = ifcElement.StepClassName; } }
/// <summary> /// Get the associated Type for a IfcObject, so a Door can be of type "Door Type A" /// </summary> /// <param name="obj">IfcObject to get associated type information from</param> /// <returns>string holding the type information</returns> protected string GetTypeName(IfcObject obj) { var value = ""; var elType = obj.IsDefinedBy.OfType <IfcRelDefinesByType>().FirstOrDefault(); if ((elType != null) && (elType.RelatingType.Name != null)) { value = elType.RelatingType.Name.ToString(); } if ((string.IsNullOrEmpty(value)) && (obj.ObjectType != null)) { value = obj.ObjectType.ToString(); } return((string.IsNullOrEmpty(value)) ? DEFAULT_STRING : value); //var elType = obj.IsDefinedBy.OfType<IfcRelDefinesByType>().FirstOrDefault(); //return (elType != null) ? elType.RelatingType.Name.ToString() : DEFAULT_STRING; }
public static TQType GetQuantity <TQType>(IfcObject elem, string qName) where TQType : IfcPhysicalQuantity { var rel = elem.IsDefinedByProperties.FirstOrDefault(r => r.RelatingPropertyDefinition is IfcElementQuantity); if (rel == null) { return(default(TQType)); } var eQ = rel.RelatingPropertyDefinition as IfcElementQuantity; if (eQ == null) { return(default(TQType)); } var result = eQ.Quantities.FirstOrDefault <TQType>(q => q.Name == qName); return(result); }
private void AddProperty(IfcObject ifcObject, IfcValue value, string cobiePropertyName, IfcPropertySet propertySet, NamedProperty namedProperty) { try { var property = TargetRepository.Instances.New <IfcPropertySingleValue>(); property.NominalValue = value; property.Description = "Converted from COBie " + cobiePropertyName; property.Name = namedProperty.PropertyName; propertySet.HasProperties.Add(property); var relDef = TargetRepository.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = propertySet; relDef.RelatedObjects.Add(ifcObject); } catch (Exception e) { throw new Exception("Failed to convert a COBie Value to and Ifc Single Value Property. " + e.Message); } }
private void FillPropertyData() { if (_properties.Count > 0) { return; //don't fill unless empty } //now the property sets for any IfcObject ifcObj = _entity as IfcObject; if (ifcObj != null) { foreach (IfcRelDefinesByProperties relDef in ifcObj.IsDefinedByProperties) { IfcPropertySet pSet = relDef.RelatingPropertyDefinition as IfcPropertySet; if (pSet != null) { foreach (var item in pSet.HasProperties.OfType <IfcPropertySingleValue>()) //only handle simple properties { string val = ""; if (item.NominalValue != null) { var nomVal = (ExpressType)(item.NominalValue); if (nomVal.Value != null) { val = nomVal.Value.ToString(); // value (not ToPart21) for visualisation } else { val = item.NominalValue.ToString(); } } _properties.Add(new PropertyItem() { PropertySetName = pSet.Name, Name = item.Name, Value = val }); } } } } }
/// <summary> /// Adds a new IfcPhysicalQuantity to the IfcElementQuantity called propertySetName /// </summary> /// <param name="elem"></param> /// <param name="propertySetName">Name of the IfcElementQuantity property set</param> /// <param name="quantity">quantity to be added</param> /// <param name="methodOfMeasurement">Sets the method of measurement, if not null overrides previous value</param> public static IfcElementQuantity AddQuantity(this IfcObject elem, string propertySetName, IfcPhysicalQuantity quantity, string methodOfMeasurement) { IfcElementQuantity pset = elem.GetElementQuantity(propertySetName); if (pset == null) { IModel model = elem.ModelOf; pset = model.Instances.New <IfcElementQuantity>(); pset.Name = propertySetName; IfcRelDefinesByProperties relDef = model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = pset; relDef.RelatedObjects.Add(elem); } pset.Quantities.Add(quantity); if (!string.IsNullOrEmpty(methodOfMeasurement)) { pset.MethodOfMeasurement = methodOfMeasurement; } return(pset); }
/// <summary> /// Get Category method /// </summary> /// <param name="obj">Object to try and extract method from</param> /// <returns></returns> public string GetCategory(IfcObject obj) { var categoryRef = GetCategoryClassification(obj); if (!string.IsNullOrEmpty(categoryRef)) { return(categoryRef); } //Try by PropertySet as fallback var query = from pSet in obj.PropertySets from props in pSet.HasProperties where props.Name.ToString() == "OmniClass Table 13 Category" || props.Name.ToString() == "Category Code" || props.Name.ToString() == "Omniclass Title" select props.ToString().TrimEnd(); var val = query.FirstOrDefault(); if (!String.IsNullOrEmpty(val)) { return(val); } return(Constants.DEFAULT_STRING); }
//Removes the current object from any RelDefinesByType relationships and adds a relationship to the specified Type public static void SetDefiningType(this IfcObject obj, IfcTypeObject typeObj, IModel model) { //divorce any exisitng related types IEnumerable <IfcRelDefinesByType> rels = model.Instances.Where <IfcRelDefinesByType>(rd => rd.RelatedObjects.Contains(obj)); foreach (var rel in rels) { rel.RelatedObjects.Remove(obj); } //find any existing relationships to this type IfcRelDefinesByType typeRel = model.Instances.Where <IfcRelDefinesByType>(rd => rd.RelatingType == typeObj).FirstOrDefault(); if (typeRel == null) //none defined create the relationship { IfcRelDefinesByType relSub = model.Instances.New <IfcRelDefinesByType>(); relSub.RelatingType = typeObj; relSub.RelatedObjects.Add(obj); } else //we have the type { typeRel.RelatedObjects.Add(obj); } }
private void FillQuantityData() { if (_quantities.Count > 0) { return; //don't fill unless empty } //now the property sets for any IfcObject ifcObj = _entity as IfcObject; // local cache for efficiency IfcUnitAssignment modelUnits = null; if (ifcObj != null) { foreach (IfcRelDefinesByProperties relDef in ifcObj.IsDefinedByProperties.Where(r => r.RelatingPropertyDefinition is IfcElementQuantity)) { IfcElementQuantity pSet = relDef.RelatingPropertyDefinition as IfcElementQuantity; if (pSet != null) { foreach (var item in pSet.Quantities.OfType <IfcPhysicalSimpleQuantity>()) //only handle simple quantities properties { if (modelUnits == null) { modelUnits = item.ModelOf.Instances.OfType <IfcUnitAssignment>().FirstOrDefault(); // not optional, should never return void in valid model } var v = modelUnits.GetUnitFor(item); _quantities.Add(new PropertyItem() { PropertySetName = pSet.Name, Name = item.Name, Value = item.ToString() + " " + v.GetName() }); } } } } }
/// <summary> /// Creates the property and if required the property set, populates them with the correct values and adds them to the IfcObject /// If the value is null or empty no property is created /// </summary> /// <param name="ifcObject">Object to associate the property with</param> /// <param name="valueBaseType">COBie value to populate the property with</param> /// <param name="cobiePropertyName">Name of the COBie property being mapped</param> /// <param name="defaultUnits">Units to use if the COBie property does not specify</param> internal bool TryCreatePropertySingleValue(IfcObject ifcObject, ValueBaseType valueBaseType, string cobiePropertyName, IfcUnitConverter?defaultUnits) { if (!valueBaseType.HasValue()) { return(false); //nothing to do } try { NamedProperty namedProperty; if (CobieToIfcPropertyMap.TryGetValue(cobiePropertyName, out namedProperty)) { var actualUnits = new IfcUnitConverter(valueBaseType.UnitName); if (actualUnits.IsUndefined && defaultUnits.HasValue) { actualUnits = defaultUnits.Value; } List <IfcPropertySetDefinition> propertySetDefinitionList; if (!_objectsToPropertySets.TryGetValue(ifcObject, out propertySetDefinitionList)) { propertySetDefinitionList = new List <IfcPropertySetDefinition>(); _objectsToPropertySets.Add(ifcObject, propertySetDefinitionList); } var propertySetDef = propertySetDefinitionList.Find(p => p.Name == namedProperty.PropertySetName); //see what sets we have against this object if (propertySetDef == 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 (namedProperty.PropertySetName.StartsWith("qto_", true, CultureInfo.InvariantCulture) || namedProperty.PropertySetName.StartsWith("basequantities", true, CultureInfo.InvariantCulture)) { var quantitySet = TargetRepository.Instances.New <IfcElementQuantity>(); propertySetDefinitionList.Add(quantitySet); quantitySet.Name = namedProperty.PropertySetName; var relDef = TargetRepository.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = quantitySet; relDef.RelatedObjects.Add(ifcObject); AddQuantity(valueBaseType, cobiePropertyName, actualUnits, quantitySet, namedProperty); } else //it is a normal property set { var propertySet = TargetRepository.Instances.New <IfcPropertySet>(); propertySetDefinitionList.Add(propertySet); propertySet.Name = namedProperty.PropertySetName; var relDef = TargetRepository.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = propertySet; relDef.RelatedObjects.Add(ifcObject); AddProperty(ifcObject, valueBaseType.ConvertToIfcValue(), cobiePropertyName, propertySet, namedProperty); } } else //need to use an existing PropertySet definition { //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 (namedProperty.PropertySetName.StartsWith("qto_", true, CultureInfo.InvariantCulture) || namedProperty.PropertySetName.StartsWith("basequantities", true, CultureInfo.InvariantCulture)) { AddQuantity(valueBaseType, cobiePropertyName, actualUnits, (IfcElementQuantity)propertySetDef, namedProperty); } else //it is a normal property set { AddProperty(ifcObject, valueBaseType.ConvertToIfcValue(), cobiePropertyName, (IfcPropertySet)propertySetDef, namedProperty); } } return(true); } throw new ArgumentException("Incorrect property map", "cobiePropertyName"); } catch (Exception e) { Debug.WriteLine("Incorrect property map, " + e.Message); Debug.Assert(false); return(false); } }
/// <summary> /// Set values for attribute sheet /// </summary> /// <param name="ifcObject">ifcObject to extract properties from</param> /// <param name="_attributes">The attribute Sheet to add the properties to its rows</param> public void PopulateAttributesRows(IfcObject ifcObject) { if (PropertSetValues.PSetFilterOn) //we have a property set filter set in the PropertSetValues class, so reset to retrieve all property sets for this object { PropertSetValues.SetAllPropertyValues(ifcObject); } foreach (KeyValuePair<IfcPropertySet, IEnumerable<IfcSimpleProperty>> pairValues in PropertSetValues.MapPsetToProps) { IfcPropertySet ps = pairValues.Key; //get Property Set //check property set exclude list if (!string.IsNullOrEmpty(ps.Name)) { if (ExcludeAttributePropertySetNames.Count() > 0) { if (ExcludeAttributePropertySetNames.Contains(ps.Name)) { continue; //skip this loop iteration if property set name matches exclude list item } } } //Get Property SetAttribSheet Property Single Values IEnumerable<IfcSimpleProperty> pSVs = pairValues.Value; //filter on ExcludePropertyValueNames and ExcludePropertyValueNamesWildcard pSVs = FilterRows(pSVs); //fill in the data to the attribute rows ProcessAttributeRow( ps, pSVs); } }
/// <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>()); }
internal XbimSingleProperties(IfcObject ifcObject) { _object = ifcObject; }
internal XbimProperties(IfcObject ifcObject, string propertySetName) { _object = ifcObject; _psetName = propertySetName; }