public static bool Add(this IIfcPropertySetDefinition pSetDefinition, IIfcPhysicalQuantity quantity) { var quantSet = pSetDefinition as IIfcElementQuantity; if (quantSet != null) { quantSet.Quantities.Add(quantity); } return(quantSet != null); }
internal static TCoBieValueBaseType ConvertAttribute <TCoBieValueBaseType>(IIfcPhysicalQuantity ifcQuantity) where TCoBieValueBaseType : AttributeValue, new() { var ifcQuantityLength = ifcQuantity as IIfcQuantityLength; var ifcQuantityArea = ifcQuantity as IIfcQuantityArea; var ifcQuantityVolume = ifcQuantity as IIfcQuantityVolume; var ifcQuantityCount = ifcQuantity as IIfcQuantityCount; var ifcQuantityWeight = ifcQuantity as IIfcQuantityWeight; var ifcQuantityTime = ifcQuantity as IIfcQuantityTime; var ifcPhysicalComplexQuantity = ifcQuantity as IIfcPhysicalComplexQuantity; var ifcPhysicalSimpleQuantity = ifcQuantity as IIfcPhysicalSimpleQuantity; var result = new TCoBieValueBaseType(); if (ifcPhysicalSimpleQuantity != null && ifcPhysicalSimpleQuantity.Unit != null) { // todo: this has been changed, it needs to be tested for values and verify that it is complete result.Unit = ifcPhysicalSimpleQuantity.Unit.FullName; } if (ifcQuantityLength != null) { SetCoBieAttributeValue(result, ifcQuantityLength.LengthValue); } else if (ifcQuantityArea != null) { SetCoBieAttributeValue(result, ifcQuantityArea.AreaValue); } else if (ifcQuantityVolume != null) { SetCoBieAttributeValue(result, ifcQuantityVolume.VolumeValue); } else if (ifcQuantityCount != null) { SetCoBieAttributeValue(result, ifcQuantityCount.CountValue); } else if (ifcQuantityWeight != null) { SetCoBieAttributeValue(result, ifcQuantityWeight.WeightValue); } else if (ifcQuantityTime != null) { SetCoBieAttributeValue(result, ifcQuantityTime.TimeValue); } else if (ifcPhysicalComplexQuantity != null) { //Logger.WarnFormat("Ifc Physical Complex Quantities values are not supported in COBie"); } else { result = null; } return(result); }
private static IfcNamedUnit resolveUnit(IIfcPhysicalQuantity quan) { IEntityCollection ifcModel = quan.Model.Instances; if (quan is IfcQuantityLength) { IfcQuantityLength ifcValue = (IfcQuantityLength)quan; return(ifcValue.Unit != null ? ifcValue.Unit : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.LENGTHUNIT))); } else if (quan is IfcQuantityArea) { IfcQuantityArea ifcValue = (IfcQuantityArea)quan; return(ifcValue.Unit != null ? ifcValue.Unit : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.AREAUNIT))); } else if (quan is IfcQuantityVolume) { IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan; return(ifcValue.Unit != null ? ifcValue.Unit : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.VOLUMEUNIT))); } else if (quan is IfcQuantityTime) { IfcQuantityTime ifcValue = (IfcQuantityTime)quan; return(ifcValue.Unit != null ? ifcValue.Unit : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.TIMEUNIT))); } else if (quan is IfcQuantityWeight) { IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan; return(ifcValue.Unit != null ? ifcValue.Unit : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.MASSUNIT))); } else if (quan is IfcQuantityCount) { IfcQuantityCount ifcValue = (IfcQuantityCount)quan; return(ifcValue.Unit); } else { return(null); } }
private static bool TryGetAttributeValue <TBaseType>(IIfcPhysicalQuantity ifcQuantity, out TBaseType result) { var ifcQuantityLength = ifcQuantity as IIfcQuantityLength; var ifcQuantityArea = ifcQuantity as IIfcQuantityArea; var ifcQuantityVolume = ifcQuantity as IIfcQuantityVolume; var ifcQuantityCount = ifcQuantity as IIfcQuantityCount; var ifcQuantityWeight = ifcQuantity as IIfcQuantityWeight; var ifcQuantityTime = ifcQuantity as IIfcQuantityTime; var ifcPhysicalComplexQuantity = ifcQuantity as IIfcPhysicalComplexQuantity; if (ifcQuantityLength != null) { return(TryGetSimpleValue(ifcQuantityLength.LengthValue, out result)); } if (ifcQuantityArea != null) { return(TryGetSimpleValue(ifcQuantityArea.AreaValue, out result)); } if (ifcQuantityVolume != null) { return(TryGetSimpleValue(ifcQuantityVolume.VolumeValue, out result)); } if (ifcQuantityCount != null) { return(TryGetSimpleValue(ifcQuantityCount.CountValue, out result)); } if (ifcQuantityWeight != null) { return(TryGetSimpleValue(ifcQuantityWeight.WeightValue, out result)); } if (ifcQuantityTime != null) { return(TryGetSimpleValue(ifcQuantityTime.TimeValue, out result)); } if (ifcPhysicalComplexQuantity != null) { //Logger.WarnFormat("Ifc Physical Complex Quantities values are not supported in COBie"); } result = default(TBaseType); return(false); }
/// <summary> /// Adds a new IfcPhysicalQuantity to the IfcElementQuantity called propertySetName /// </summary> /// <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 IIfcElementQuantity AddQuantity(string propertySetName, IIfcPhysicalQuantity quantity, string methodOfMeasurement) { var pset = GetElementQuantity(propertySetName); if (pset == null) { pset = Model.Instances.New <IfcElementQuantity>(); pset.Name = propertySetName; var relDef = Model.Instances.New <IfcRelDefinesByProperties>(); relDef.RelatingPropertyDefinition = pset; relDef.RelatedObjects.Add(this); } pset.Quantities.Add(quantity); if (!string.IsNullOrEmpty(methodOfMeasurement)) { pset.MethodOfMeasurement = methodOfMeasurement; } return(pset); }
private bool TryGetAttributeValue <TBaseType>(IIfcPhysicalQuantity ifcQuantity, out TBaseType result) { if (ifcQuantity is IIfcQuantityLength ifcQuantityLength) { return(TryGetSimpleValue(ifcQuantityLength.LengthValue, out result)); } if (ifcQuantity is IIfcQuantityArea ifcQuantityArea) { return(TryGetSimpleValue(ifcQuantityArea.AreaValue, out result)); } if (ifcQuantity is IIfcQuantityVolume ifcQuantityVolume) { return(TryGetSimpleValue(ifcQuantityVolume.VolumeValue, out result)); } if (ifcQuantity is IIfcQuantityCount ifcQuantityCount) { return(TryGetSimpleValue(ifcQuantityCount.CountValue, out result)); } if (ifcQuantity is IIfcQuantityWeight ifcQuantityWeight) { return(TryGetSimpleValue(ifcQuantityWeight.WeightValue, out result)); } if (ifcQuantity is IIfcQuantityTime ifcQuantityTime) { return(TryGetSimpleValue(ifcQuantityTime.TimeValue, out result)); } if (ifcQuantity is IIfcPhysicalComplexQuantity ifcPhysicalComplexQuantity) { //Logger.WarnFormat("Ifc Physical Complex Quantities values are not supported in COBie"); } result = default(TBaseType); return(false); }
private static IfcUnit resolveUnit(IIfcPhysicalQuantity quan) { if (quan is IfcQuantityLength) { IfcQuantityLength ifcValue = (IfcQuantityLength)quan; return(ifcValue.Unit); } else if (quan is IfcQuantityArea) { IfcQuantityArea ifcValue = (IfcQuantityArea)quan; return(ifcValue.Unit); } else if (quan is IfcQuantityVolume) { IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan; return(ifcValue.Unit); } else if (quan is IfcQuantityTime) { IfcQuantityTime ifcValue = (IfcQuantityTime)quan; return(ifcValue.Unit); } else if (quan is IfcQuantityWeight) { IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan; return(ifcValue.Unit); } else if (quan is IfcQuantityCount) { IfcQuantityCount ifcValue = (IfcQuantityCount)quan; return(ifcValue.Unit); } else { return(null); } }
private static IfcValue resolveValue(IIfcPhysicalQuantity quan) { if (quan is IfcQuantityLength) { IfcQuantityLength ifcValue = (IfcQuantityLength)quan; return(new IfcLengthMeasure(ifcValue.LengthValue.ToString())); } else if (quan is IfcQuantityArea) { IfcQuantityArea ifcValue = (IfcQuantityArea)quan; return(new IfcAreaMeasure(ifcValue.AreaValue.ToString())); } else if (quan is IfcQuantityVolume) { IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan; return(new IfcVolumeMeasure(ifcValue.VolumeValue.ToString())); } else if (quan is IfcQuantityTime) { IfcQuantityTime ifcValue = (IfcQuantityTime)quan; return(new IfcTimeMeasure(ifcValue.TimeValue.ToString())); } else if (quan is IfcQuantityWeight) { IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan; return(new IfcMassMeasure(ifcValue.WeightValue)); } else if (quan is IfcQuantityCount) { IfcQuantityCount ifcValue = (IfcQuantityCount)quan; return(new IfcCountMeasure(ifcValue.CountValue.ToString())); } else { return(null); } }
/// <summary> /// Adds a new IfcPhysicalQuantity to the IfcElementQuantity called propertySetName /// </summary> /// <param name="propertySetName">Name of the IfcElementQuantity property set</param> /// <param name="quantity">quantity to be added</param> public IIfcElementQuantity AddQuantity(string propertySetName, IIfcPhysicalQuantity quantity) { return(AddQuantity(propertySetName, quantity, null)); }