internal XbimMaterialQuantities(IfcTypeObject ifcTypeObject, XbimDocument document) { if (ifcTypeObject == null || document == null) throw new ArgumentNullException(); _typeObject = ifcTypeObject; _object = null; _document = document; }
public static IfcPropertySingleValue SetPropertySingleValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyName, IfcValue value) { IfcPropertySet pset = GetPropertySet(obj, pSetName); IfcPropertySingleValue property = null; IModel model = null; if (pset == null) { //if (value == null) return; IPersistIfcEntity ent = obj as IPersistIfcEntity; model = ent != null? ent.ModelOf : obj.ModelOf; pset = model.Instances.New <IfcPropertySet>(); pset.Name = pSetName; obj.AddPropertySet(pset); } //change existing property of the same name from the property set IfcPropertySingleValue singleVal = GetPropertySingleValue(obj, pSetName, propertyName); if (singleVal != null) { property = singleVal; singleVal.NominalValue = value; } else { //if (value == null) return; IPersistIfcEntity ent = obj as IPersistIfcEntity; model = ent != null ? ent.ModelOf : obj.ModelOf; property = model.Instances.New <IfcPropertySingleValue>(psv => { psv.Name = propertyName; psv.NominalValue = value; }); pset.HasProperties.Add(property); } return(property); }
public static IfcValue GetPropertyTableItemValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyTableName, IfcValue definingValue) { IfcPropertyTableValue table = GetPropertyTableValue(obj, pSetName, propertyTableName); if (table == null) { return(null); } IList <IfcValue> definingValues = table.DefiningValues; if (definingValues == null) { return(null); } if (!definingValues.Contains(definingValue)) { return(null); } int index = definingValues.IndexOf(definingValue); if (table.DefinedValues.Count < index + 1) { return(null); } return(table.DefinedValues[index]); }
internal XbimQuantities(IfcTypeObject ifcTypeObject, string propertySetName) { if (ifcTypeObject == null || propertySetName == null || propertySetName == "") throw new ArgumentNullException(); _psetName = propertySetName; _ifcObject = null; _ifcTypeObject = ifcTypeObject ; SetMetersAndMilimetersAsBaseUnit(ifcTypeObject); }
public static void DeletePropertySingleValueValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyName) { IfcPropertySingleValue psv = GetPropertySingleValue(obj, pSetName, propertyName); if (psv != null) { psv.NominalValue = null; } }
public static IfcPropertySingleValue GetPropertySingleValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyName) { IfcPropertySet pset = GetPropertySet(obj, pSetName); if (pset != null) { return(pset.HasProperties.Where <IfcPropertySingleValue>(p => p.Name == propertyName).FirstOrDefault()); } return(null); }
/// <summary> /// Returns the propertyset of the specified name, null if it does not exist /// </summary> /// <param name="obj"></param> /// <param name="pSetName"></param> /// <returns></returns> public static IfcPropertySet GetPropertySet(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, bool caseSensitive = true) { if (obj.HasPropertySets == null) { return(null); } else { return(caseSensitive ? obj.HasPropertySets.Where <IfcPropertySet>(r => r.Name == pSetName).FirstOrDefault() : obj.HasPropertySets.Where <IfcPropertySet>(r => r.Name.ToString().ToLower() == pSetName.ToLower()).FirstOrDefault()); } }
public static List <IfcPropertySet> GetAllPropertySets(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj) { List <IfcPropertySet> result = new List <IfcPropertySet>(); if (obj.HasPropertySets != null) { foreach (IfcPropertySetDefinition def in obj.HasPropertySets) { if (def is IfcPropertySet) { result.Add(def as IfcPropertySet); } } } return(result); }
public static void SetPropertyTableItemValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyTableName, IfcValue definingValue, IfcValue definedValue, IfcUnit definingUnit, IfcUnit definedUnit) { IfcPropertySet pset = GetPropertySet(obj, pSetName); IModel model = null; if (pset == null) { IPersistIfcEntity ent = obj as IPersistIfcEntity; model = ent != null ? ent.ModelOf : obj.ModelOf; pset = model.Instances.New <IfcPropertySet>(); pset.Name = pSetName; obj.AddPropertySet(pset); } IfcPropertyTableValue table = GetPropertyTableValue(obj, pSetName, propertyTableName); if (table == null) { IPersistIfcEntity ent = obj as IPersistIfcEntity; model = ent != null ? ent.ModelOf : obj.ModelOf; table = model.Instances.New <IfcPropertyTableValue>(tb => { tb.Name = propertyTableName; }); pset.HasProperties.Add(table); table.DefinedUnit = definedUnit; table.DefiningUnit = definingUnit; } if (table.DefiningUnit != definingUnit || table.DefinedUnit != definedUnit) { throw new Exception("Inconsistent definition of the units in the property table."); } IfcValue itemValue = GetPropertyTableItemValue(obj, pSetName, propertyTableName, definingValue); if (itemValue != null) { itemValue = definedValue; } else { table.DefiningValues.Add(definingValue); table.DefinedValues.Add(definedValue); //check of integrity if (table.DefinedValues.Count != table.DefiningValues.Count) { throw new Exception("Inconsistent state of the property table. Number of defined and defining values are not the same."); } } }
/// <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>>(); }
public override void IfcParse(int propIndex, IPropertyValue value) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: base.IfcParse(propIndex, value); break; case 5: _relatingType = (IfcTypeObject) value.EntityVal; break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: base.Parse(propIndex, value, nestedIndex); return; case 5: _relatingType = (IfcTypeObject)(value.EntityVal); return; default: throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper())); } }
public override void IfcParse(int propIndex, IPropertyValue value) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: base.IfcParse(propIndex, value); break; case 5: _relatingType = (IfcTypeObject)value.EntityVal; break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
/// <summary> /// Adds an element type to the object if it doesn't already have one, return the new or existing relationship that holds the type and this element. If there is a relationship for this type but this element is not related it adds it to the exosting relationship /// </summary> /// <param name="theType"></param> /// <returns></returns> public IfcRelDefinesByType AddDefiningType(IfcTypeObject theType) { var typedefs = Model.Instances.Where <IfcRelDefinesByType>(r => r.RelatingType == theType).ToList(); var thisTypeDef = typedefs.FirstOrDefault(r => r.RelatedObjects.Contains((this))); if (thisTypeDef != null) { return(thisTypeDef); // it is already type related } var anyTypeDef = typedefs.FirstOrDefault(); //take any one of the rels of the type if (anyTypeDef != null) { anyTypeDef.RelatedObjects.Add(this); return(anyTypeDef); } var newdef = Model.Instances.New <IfcRelDefinesByType>(); //create one newdef.RelatedObjects.Add(this); newdef.RelatingType = theType; return(newdef); }
/// <summary> /// Set values for attribute sheet /// </summary> /// <param name="ifcTypeObject">ifcObject to extract properties from</param> /// <param name="_attributes">The attribute Sheet to add the properties to its rows</param> public void PopulateAttributesRows(IfcTypeObject ifcTypeObject) { 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(ifcTypeObject); } foreach (KeyValuePair<IfcPropertySet, IEnumerable<IfcSimpleProperty>> pairValues in PropertSetValues.MapPsetToProps) { IfcPropertySet ps = pairValues.Key; //get Property Set //get all property attached to the 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 } } } IEnumerable<IfcSimpleProperty> pSVs = pairValues.Value; //Get Property SetAttribSheet Property Single Values //filter on ExcludePropertyValueNames and ExcludePropertyValueNamesWildcard pSVs = FilterRows(pSVs); //fill in the data to the attribute rows ProcessAttributeRow( ps, pSVs); } }
public AssetTypeInfoType(IfcTypeObject ifcTypeObject, CoBieLiteHelper helper) : this() { externalEntityName = helper.ExternalEntityName(ifcTypeObject); externalID = helper.ExternalEntityIdentity(ifcTypeObject); externalSystemName = helper.ExternalSystemName(ifcTypeObject); AssetTypeName = ifcTypeObject.Name; AssetTypeCategory = helper.GetClassification(ifcTypeObject); string accCategoryString = helper.GetCoBieProperty("AssetTypeAccountingCategory", ifcTypeObject); AssetPortabilitySimpleType accCategoryEnum; if (Enum.TryParse(accCategoryString, true, out accCategoryEnum)) AssetTypeAccountingCategory = accCategoryEnum; else { CoBieLiteHelper.Logger.WarnFormat("AssetTypeAccountingCategory: An illegal value of [{0}] has been passed for the category of #{1}={2}. It has been replaced with a value of 'Item'", accCategoryString, ifcTypeObject.EntityLabel, ifcTypeObject.GetType().Name); AssetTypeAccountingCategory = AssetPortabilitySimpleType.Item; } if (string.IsNullOrWhiteSpace(AssetTypeCategory)) //try the asset assignment { IfcAsset ifcAsset; if(helper.AssetAsignments.TryGetValue(ifcTypeObject, out ifcAsset)) AssetTypeCategory = helper.GetCoBieAttribute<StringValueType>("AssetTypeAccountingCategory", ifcAsset).StringValue; } AssetTypeDescription = ifcTypeObject.Description; AssetTypeModelNumber = helper.GetCoBieProperty("AssetTypeModelNumber", ifcTypeObject); AssetTypeReplacementCostValue = helper.GetCoBieAttribute<DecimalValueType>("AssetTypeReplacementCostValue", ifcTypeObject); AssetTypeExpectedLifeValue = helper.GetCoBieAttribute<IntegerValueType>("AssetTypeExpectedLifeValue", ifcTypeObject); AssetTypeNominalLength = helper.GetCoBieAttribute<DecimalValueType>("AssetTypeNominalLength", ifcTypeObject); AssetTypeNominalWidth = helper.GetCoBieAttribute<DecimalValueType>("AssetTypeNominalWidth", ifcTypeObject); AssetTypeNominalHeight = helper.GetCoBieAttribute<DecimalValueType>("AssetTypeNominalHeight", ifcTypeObject); AssetTypeAccessibilityText = helper.GetCoBieProperty("AssetTypeAccessibilityText", ifcTypeObject); AssetTypeColorCode = helper.GetCoBieProperty("AssetTypeColorCode", ifcTypeObject); AssetTypeConstituentsDescription = helper.GetCoBieProperty("AssetTypeConstituentsDescription", ifcTypeObject); AssetTypeFeaturesDescription = helper.GetCoBieProperty("AssetTypeFeaturesDescription", ifcTypeObject); AssetTypeGradeDescription = helper.GetCoBieProperty("AssetTypeGradeDescription", ifcTypeObject); AssetTypeMaterialDescription = helper.GetCoBieProperty("AssetTypeMaterialDescription", ifcTypeObject); AssetTypeShapeDescription = helper.GetCoBieProperty("AssetTypeShapeDescription", ifcTypeObject); AssetTypeSizeDescription = helper.GetCoBieProperty("AssetTypeSizeDescription", ifcTypeObject); AssetTypeSustainabilityPerformanceDescription = helper.GetCoBieProperty("AssetTypeSustainabilityPerformanceDescription", ifcTypeObject); //The Assets List<IfcElement> allAssetsofThisType; if (helper.DefiningTypeObjectMap.TryGetValue(ifcTypeObject, out allAssetsofThisType)) //should always work { Assets = new AssetCollectionType { Asset = new List<AssetInfoType>(allAssetsofThisType.Count)}; foreach (IfcElement t in allAssetsofThisType) { Assets.Add(new AssetInfoType(t, helper)); } } else { //just in case we have a problem CoBieLiteHelper.Logger.ErrorFormat("Asset Type: Failed to locate Asset Type #{0}={1}", ifcTypeObject.EntityLabel,ifcTypeObject.GetType().Name); } //Attributes var ifcAttributes = helper.GetAttributes(ifcTypeObject); if (ifcAttributes != null && ifcAttributes.Any()) AssetTypeAttributes = new AttributeCollectionType { Attribute = ifcAttributes }; }
internal XbimSingleTypeProperties(IfcTypeObject ifcObject) { _object = ifcObject; }
public static void SetPropertyTableItemValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyTableName, IfcValue definingValue, IfcValue definedValue) { SetPropertyTableItemValue(obj, pSetName, propertyTableName, definingValue, definedValue, null, null); }
public static IfcValue GetPropertySingleValueValue(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj, string pSetName, string propertyName) { IfcPropertySingleValue psv = GetPropertySingleValue(obj, pSetName, propertyName); return(psv.NominalValue); }
/// <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 } } } }
public static Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > GetAllPropertySingleValues(this Xbim.Ifc2x3.Kernel.IfcTypeObject obj) { Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> > result = new Dictionary <IfcLabel, Dictionary <IfcIdentifier, IfcValue> >(); PropertySetDefinitionSet pSets = obj.HasPropertySets; if (pSets == null) { return(result); } IEnumerable <IfcPropertySet> pSetsPure = pSets.OfType <IfcPropertySet>(); foreach (IfcPropertySet pSet in pSetsPure) { Dictionary <IfcIdentifier, IfcValue> value = new Dictionary <IfcIdentifier, IfcValue>(); IfcLabel psetName = pSet.Name ?? null; foreach (IfcProperty prop in pSet.HasProperties) { IfcPropertySingleValue singleVal = prop as IfcPropertySingleValue; if (singleVal == null) { continue; } value.Add(prop.Name, singleVal.NominalValue); } result.Add(psetName, value); } return(result); }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="typeObject"></param> /// <param name="typeName"></param> public XbimIfcProxyTypeObject(CoBieLiteUkHelper helper, IfcTypeObject typeObject, string typeName) { _ifcTypeObject = typeObject; _helper = helper; _name = typeName; }
/// <summary> /// Check all ifcElements associated with the pass ifcTypeObject for the passed property map key. /// If all found elements of the property are the same then we assume that the property applies to the type as well as all the elements /// </summary> /// <param name="valueName">property map key</param> /// <param name="ifcTypeObject">ifcTypeObject</param> /// <returns>property value</returns> private string GetObjPropByAssoc(string valueName, IfcTypeObject ifcTypeObject) { string accCategoryString = string.Empty; var ObjDefByType = _helper.DefiningTypeObjectMap.Where(pair => (pair.Key.IfcTypeObject != null) && (pair.Key.IfcTypeObject == ifcTypeObject)).SelectMany(p => p.Value); var assetTypes = new List<string>(); foreach (var item in ObjDefByType) { accCategoryString = _helper.GetCoBieProperty(valueName, item); assetTypes.Add(accCategoryString != null ? accCategoryString : string.Empty); } //assume every ifcElement hast to have the value and be set to the same value if (assetTypes.Count > 0) { var fat = assetTypes.First(); if (assetTypes.All(at => at == fat)) { return accCategoryString; } } return null; }