Skip to content

Units

The snaptrude.project.units namespace handles unit conversions and formatting.

Types

  • UnitType: Enum representing supported units (e.g., meters, feet, inches).

Functions

toProjectUnits(value: number, fromUnit: UnitType)

Converts a value from a specific unit to the current project's internal unit system.

  • Parameters:
    • value: number - The value to convert.
    • fromUnit: UnitType - The source unit of the value.
  • Returns: number - The converted value.

fromProjectUnits(value: number, toUnit: UnitType)

Converts a value from the current project's internal unit system to a specific target unit.

  • Parameters:
    • value: number - The value in project units.
    • toUnit: UnitType - The target unit.
  • Returns: number - The converted value.

format(value: number)

Formats a numeric value as a string according to the project's unit display settings (e.g., "10' 6"" or "3.2 m").

  • Parameters:
    • value: number - The value in project units.
  • Returns: string - The formatted string.