Esempio n. 1
0
        private string FormatBoundedValue(IFCPropertyValue propertyValue)
        {
            if (IFCUnit != null)
            {
                FormatValueOptions formatValueOptions = new FormatValueOptions();
                FormatOptions      specFormatOptions  = IFCImportFile.TheFile.Document.GetUnits().GetFormatOptions(IFCUnit.Spec);
                specFormatOptions.Accuracy = 1e-8;
                if (specFormatOptions.CanSuppressTrailingZeros())
                {
                    specFormatOptions.SuppressTrailingZeros = true;
                }
                formatValueOptions.SetFormatOptions(specFormatOptions);

                // If ScaleValues is false, value is in source file units, but 'UnitFormatUtils.Format' expects
                // it in internal units and it then converts it to display units, which should be the same as
                // the source file units.
                double value = Importer.TheProcessor.ScaleValues ?
                               propertyValue.AsDouble() :
                               UnitUtils.ConvertToInternalUnits(propertyValue.AsDouble(), specFormatOptions.GetUnitTypeId());

                return(UnitFormatUtils.Format(IFCImportFile.TheFile.Document.GetUnits(), IFCUnit.Spec, value, false, formatValueOptions));
            }
            else
            {
                return(propertyValue.ValueAsString());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Convert a value into a formatted length string as displayed in Revit.
        /// </summary>
        /// <param name="value">The value, in Revit internal units.</param>
        /// <returns>The formatted string representation.</returns>
        static public string FormatLengthAsString(double value)
        {
            FormatValueOptions formatValueOptions = new FormatValueOptions();

            formatValueOptions.AppendUnitSymbol = true;
            FormatOptions lengthFormatOptions = IFCImportFile.TheFile.Document.GetUnits().GetFormatOptions(SpecTypeId.Length);

            lengthFormatOptions.Accuracy = 1e-8;
            if (lengthFormatOptions.CanSuppressTrailingZeros())
            {
                lengthFormatOptions.SuppressTrailingZeros = true;
            }
            formatValueOptions.SetFormatOptions(lengthFormatOptions);
            return(UnitFormatUtils.Format(IFCImportFile.TheFile.Document.GetUnits(), SpecTypeId.Length, value, false, formatValueOptions));
        }
Esempio n. 3
0
 private string FormatBoundedValue(IFCPropertyValue propertyValue)
 {
     if (IFCUnit != null)
     {
         FormatValueOptions formatValueOptions = new FormatValueOptions();
         FormatOptions      specFormatOptions  = IFCImportFile.TheFile.Document.GetUnits().GetFormatOptions(IFCUnit.Spec);
         specFormatOptions.Accuracy = 1e-8;
         if (specFormatOptions.CanSuppressTrailingZeros())
         {
             specFormatOptions.SuppressTrailingZeros = true;
         }
         formatValueOptions.SetFormatOptions(specFormatOptions);
         return(UnitFormatUtils.Format(IFCImportFile.TheFile.Document.GetUnits(), IFCUnit.Spec, propertyValue.AsDouble(), false, formatValueOptions));
     }
     else
     {
         return(propertyValue.ValueAsString());
     }
 }