Skip to content

ImperialUnitService

Canonical path: NemAll_Python_AllplanSettings.ImperialUnitService

Utility class offering methods for conversion from metric into imperial units

ConvertToMM staticmethod

ConvertToMM(imperialValue: str) -> tuple

Convert an imperial length unit to mm

Parameters:

  • imperialValue (str) –

    Imperial value as string

Returns:

  • tuple

    True when conversion failed, False when it was successful

  • tuple

    Length in millimeters

Examples:

>>> ImperialUnitService.ConvertToMM("4'6"")
(False, 1371.6)
>>> ConvertToMM("0"")
(False, 0.0)
>>> ConvertToMM("4 in")
(True, 0.0)

ConvertTokg staticmethod

ConvertTokg(imperialValue: str) -> tuple

Convert an imperial weight unit to kg

Parameters:

  • imperialValue (str) –

    Imperial value as string

Returns:

  • tuple

    True when conversion failed, False when it was successful

  • tuple

    Weight in kilograms

Examples:

>>> ImperialUnitService.ConvertTokg("4 lb")
(False, 1.814368)
>>> ImperialUnitService.ConvertTokg("0 lb")
(False, 0.0)
>>> ImperialUnitService.ConvertTokg("4 oz")
(True, 0.0)

IsImperialUnit staticmethod

IsImperialUnit() -> bool

Check whether the current input unit is imperial unit

Returns:

  • bool

    Imperial unit input: True/False

Placeholder