/// <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); }