Skip to content

ImperialUnitService

Canonical path: NemAll_Python_AllplanSettings.ImperialUnitService

Utility class offering methods for conversion from metric into imperial units

Methods:

  • ConvertToMM

    Convert length given in imperial unit to millimeters

  • ConvertTokg

    Convert an weight given in imperial unit to kilograms

  • IsImperialUnit

    Check whether the current input unit is imperial unit

ConvertToMM staticmethod

ConvertToMM(imperialValue: str) -> tuple

Convert length given in imperial unit to millimeters

Parameters:

  • imperialValue (str) –

    Length given in imperial values 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 weight given in imperial unit to kilograms

Parameters:

  • imperialValue (str) –

    Wight given in imperial values 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