BimCT SDK / WebGL2 Viewer
    Preparing search index...

    Function formatToMetric

    • Converts a given value and its unit into a standardized metric equivalent.

      Parameters

      • unit: string

        The original unit of the value. Supported units include:

        • Linear: 'M', 'IN', 'FT'
        • Area: 'FT2', 'YD2'
        • Volume: 'FT3', 'YD3'
        • Weight: 'LB'
      • value: number

        The value associated with the given unit to be converted.

      Returns { unit: string; value: number }

      • An object containing:
        • unit: The converted metric unit (e.g., 'MM', 'M2', 'M3', 'KG').
        • value: The converted value in the metric system.
      • formatToMetric('IN', 12) returns { unit: 'MM', value: 304.8 } (12 inches to millimeters).
      • formatToMetric('FT2', 100) returns { unit: 'M2', value: 9.2903 } (100 square feet to square meters).
      • formatToMetric('LB', 50) returns { unit: 'KG', value: 22.6796 } (50 pounds to kilograms).
      • The function automatically standardizes unit strings, replacing Unicode superscripts (² or ³) with numeric equivalents (2 or 3).
      • If the provided unit is not supported, the input is returned unchanged.