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 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."); } } }