public static void SetElementPhysicalSimpleQuantity(this IfcTypeObject elem, string qSetName, string qualityName, double value, XbimQuantityTypeEnum quantityType, IfcNamedUnit unit) { IModel model = null; if (elem is IPersistIfcEntity) model = (elem as IPersistIfcEntity).ModelOf; else model = elem.ModelOf; IfcElementQuantity qset = GetElementQuantity(elem, qSetName); if (qset == null) { qset = model.Instances.New<IfcElementQuantity>(); qset.Name = qSetName; if (elem.HasPropertySets == null) elem.CreateHasPropertySets(); elem.HasPropertySets.Add(qset); } //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 = value); break; case XbimQuantityTypeEnum.COUNT: simpleQuality = model.Instances.New<IfcQuantityCount>(sq => sq.CountValue = value); break; case XbimQuantityTypeEnum.LENGTH: simpleQuality = model.Instances.New<IfcQuantityLength>(sq => sq.LengthValue = value); break; case XbimQuantityTypeEnum.TIME: simpleQuality = model.Instances.New<IfcQuantityTime>(sq => sq.TimeValue = value); break; case XbimQuantityTypeEnum.VOLUME: simpleQuality = model.Instances.New<IfcQuantityVolume>(sq => sq.VolumeValue = value); break; case XbimQuantityTypeEnum.WEIGHT: simpleQuality = model.Instances.New<IfcQuantityWeight>(sq => sq.WeightValue = value); break; default: return; } simpleQuality.Unit = unit; simpleQuality.Name = qualityName; qset.Quantities.Add(simpleQuality); }
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); }
public void SetElementPhysicalSimpleQuantity(string qSetName, string qualityName, double value, XbimQuantityTypeEnum quantityType, IfcNamedUnit unit) { var qset = GetElementQuantity(qSetName) as IfcElementQuantity; if (qset == null) { qset = Model.Instances.New <IfcElementQuantity>(); qset.Name = qSetName; var relDef = Model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = qset; relDef.RelatedObjects.Add(this); } //remove existing simple quality var simpleQuantity = GetElementPhysicalSimpleQuantity(qSetName, qualityName) as IfcPhysicalSimpleQuantity; if (simpleQuantity == null) { switch (quantityType) { case XbimQuantityTypeEnum.Area: simpleQuantity = Model.Instances.New <IfcQuantityArea>(sq => sq.AreaValue = (IfcAreaMeasure)value); break; case XbimQuantityTypeEnum.Count: simpleQuantity = Model.Instances.New <IfcQuantityCount>(sq => sq.CountValue = (IfcCountMeasure)value); break; case XbimQuantityTypeEnum.Length: simpleQuantity = Model.Instances.New <IfcQuantityLength>(sq => sq.LengthValue = (IfcLengthMeasure)value); break; case XbimQuantityTypeEnum.Time: simpleQuantity = Model.Instances.New <IfcQuantityTime>(sq => sq.TimeValue = (IfcTimeMeasure)value); break; case XbimQuantityTypeEnum.Volume: simpleQuantity = Model.Instances.New <IfcQuantityVolume>(sq => sq.VolumeValue = (IfcVolumeMeasure)value); break; case XbimQuantityTypeEnum.Weight: simpleQuantity = Model.Instances.New <IfcQuantityWeight>(sq => sq.WeightValue = (IfcMassMeasure)value); break; default: return; } } else { switch (quantityType) { case XbimQuantityTypeEnum.Area: ((IfcQuantityArea)simpleQuantity).AreaValue = new IfcAreaMeasure(value); break; case XbimQuantityTypeEnum.Count: ((IfcQuantityCount)simpleQuantity).CountValue = new IfcCountMeasure(value); break; case XbimQuantityTypeEnum.Length: ((IfcQuantityLength)simpleQuantity).LengthValue = new IfcLengthMeasure(value); break; case XbimQuantityTypeEnum.Time: ((IfcQuantityTime)simpleQuantity).TimeValue = new IfcTimeMeasure(value); break; case XbimQuantityTypeEnum.Volume: ((IfcQuantityVolume)simpleQuantity).VolumeValue = new IfcVolumeMeasure(value); break; case XbimQuantityTypeEnum.Weight: ((IfcQuantityWeight)simpleQuantity).WeightValue = new IfcMassMeasure(value); break; default: return; } } simpleQuantity.Unit = unit; simpleQuantity.Name = qualityName; qset.Quantities.Add(simpleQuantity); }
protected void SetOrRemoveQuantity(string quantityName, XbimQuantityTypeEnum quantityType, double? value) { if (value == null) { RemoveQuantity(quantityName); } else { double val = value ?? 0; SetQuantity(quantityName, quantityType, val); } }
private void SetQuantity(string quantityName, XbimQuantityTypeEnum quantityType, double value) { if (_ifcObject != null) { switch (quantityType) { case XbimQuantityTypeEnum.AREA: _ifcObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, _areaUnit); break; case XbimQuantityTypeEnum.COUNT: _ifcObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, null); break; case XbimQuantityTypeEnum.LENGTH: _ifcObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, _lengthUnit); break; case XbimQuantityTypeEnum.TIME: _ifcObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, null); break; case XbimQuantityTypeEnum.VOLUME: _ifcObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, _volumeUnit); break; case XbimQuantityTypeEnum.WEIGHT: _ifcObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, null); break; } } else { switch (quantityType) { case XbimQuantityTypeEnum.AREA: _ifcTypeObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, _areaUnit); break; case XbimQuantityTypeEnum.COUNT: _ifcTypeObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, null); break; case XbimQuantityTypeEnum.LENGTH: _ifcTypeObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, _lengthUnit); break; case XbimQuantityTypeEnum.TIME: _ifcTypeObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, null); break; case XbimQuantityTypeEnum.VOLUME: _ifcTypeObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, _volumeUnit); break; case XbimQuantityTypeEnum.WEIGHT: _ifcTypeObject.SetElementPhysicalSimpleQuantity(_psetName, quantityName, value, quantityType, null); break; } } }
public static void SetElementPhysicalSimpleQuantity(this IfcTypeObject elem, string qSetName, string qualityName, double value, XbimQuantityTypeEnum quantityType, IfcNamedUnit unit) { IModel model = null; if (elem is IPersistIfcEntity) { model = (elem as IPersistIfcEntity).ModelOf; } else { model = elem.ModelOf; } IfcElementQuantity qset = GetElementQuantity(elem, qSetName); if (qset == null) { qset = model.Instances.New <IfcElementQuantity>(); qset.Name = qSetName; if (elem.HasPropertySets == null) { elem.CreateHasPropertySets(); } elem.HasPropertySets.Add(qset); } //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 = value); break; case XbimQuantityTypeEnum.COUNT: simpleQuality = model.Instances.New <IfcQuantityCount>(sq => sq.CountValue = value); break; case XbimQuantityTypeEnum.LENGTH: simpleQuality = model.Instances.New <IfcQuantityLength>(sq => sq.LengthValue = value); break; case XbimQuantityTypeEnum.TIME: simpleQuality = model.Instances.New <IfcQuantityTime>(sq => sq.TimeValue = value); break; case XbimQuantityTypeEnum.VOLUME: simpleQuality = model.Instances.New <IfcQuantityVolume>(sq => sq.VolumeValue = value); break; case XbimQuantityTypeEnum.WEIGHT: simpleQuality = model.Instances.New <IfcQuantityWeight>(sq => sq.WeightValue = value); break; default: return; } simpleQuality.Unit = unit; simpleQuality.Name = qualityName; qset.Quantities.Add(simpleQuality); }