BimCT SDK / WebGL2 Viewer
    Preparing search index...

    Function formatLength

    • Formats a length value into a human-readable string, either in metric or imperial units.

      Parameters

      • lengthInMM: number

        The length value in millimeters to format.

      • isImperial: boolean

        Determines whether to format the output in imperial units (feet/inches) or metric units.

      • Optionalnegative: boolean = false

        Optional flag indicating if the length should be prefixed with a negative sign.

      Returns string

      • A formatted string representing the length in the desired unit system.
      • formatLength(1000, false) returns "1 m"
      • formatLength(304.8, true) returns "1'" (1 foot in imperial)
      • formatLength(-1234, false, true) returns "- 1.234 m"
      • For imperial formatting, lengths are displayed as feet, inches, and simplified fractions of an inch (to the nearest 1/16).
      • Metric lengths less than 1 meter are displayed in millimeters, and lengths over 1 kilometer are displayed in kilometers.