コード例 #1
0
        private static string GetUnit(IIfcUnitAssignment units, IfcUnitEnum type)
        {
            if (units == null)
            {
                return(null);
            }
            var unit = units.Units.OfType <IIfcNamedUnit>().FirstOrDefault(u => u.UnitType == type);

            return(unit != null ? unit.FullName : null);
        }
コード例 #2
0
 private void AddQuantityPSet(IIfcElementQuantity pSet, IIfcUnitAssignment modelUnits)
 {
     if (pSet == null)
     {
         return;
     }
     if (modelUnits == null)
     {
         throw new ArgumentNullException(nameof(modelUnits));
     }
     foreach (var item in pSet.Quantities.OfType <IIfcPhysicalSimpleQuantity>())
     // currently only handles IfcPhysicalSimpleQuantity
     {
         _quantities.Add(new PropertyItem
         {
             PropertySetName = pSet.Name,
             Name            = item.Name,
             Value           = GetValueString(item, modelUnits)
         });
     }
 }
コード例 #3
0
        private static string GetUnit(IIfcUnitAssignment units, IfcUnitEnum type)
        {
            var unit = units?.Units.OfType <IIfcNamedUnit>().FirstOrDefault(u => u.UnitType == type);

            return(unit?.FullName);
        }
コード例 #4
0
        private static string GetValueString(IIfcPhysicalSimpleQuantity quantity, IIfcUnitAssignment modelUnits)
        {
            if (quantity == null)
            {
                return("");
            }
            string value    = null;
            var    unitName = "";
            var    u        = quantity.Unit;

            if (quantity.Unit != null)
            {
                unitName = quantity.Unit.FullName;
            }

            var length = quantity as IIfcQuantityLength;

            if (length != null)
            {
                value = length.LengthValue.ToString();
                if (quantity.Unit == null)
                {
                    unitName = GetUnit(modelUnits, IfcUnitEnum.LENGTHUNIT);
                }
            }
            var area = quantity as IIfcQuantityArea;

            if (area != null)
            {
                value = area.AreaValue.ToString();
                if (quantity.Unit == null)
                {
                    unitName = GetUnit(modelUnits, IfcUnitEnum.AREAUNIT);
                }
            }
            var weight = quantity as IIfcQuantityWeight;

            if (weight != null)
            {
                value = weight.WeightValue.ToString();
                if (quantity.Unit == null)
                {
                    unitName = GetUnit(modelUnits, IfcUnitEnum.MASSUNIT);
                }
            }
            var time = quantity as IIfcQuantityTime;

            if (time != null)
            {
                value = time.TimeValue.ToString();
                if (quantity.Unit == null)
                {
                    unitName = GetUnit(modelUnits, IfcUnitEnum.TIMEUNIT);
                }
            }
            var volume = quantity as IIfcQuantityVolume;

            if (volume != null)
            {
                value = volume.VolumeValue.ToString();
                if (quantity.Unit == null)
                {
                    unitName = GetUnit(modelUnits, IfcUnitEnum.VOLUMEUNIT);
                }
            }
            var count = quantity as IIfcQuantityCount;

            if (count != null)
            {
                value = count.CountValue.ToString();
            }


            if (string.IsNullOrWhiteSpace(value))
            {
                return("");
            }

            return(string.IsNullOrWhiteSpace(unitName) ?
                   value :
                   $"{value} {unitName}");
        }