Skip to content

ImperialUnitService

Canonical path: NemAll_Python_AllplanSettings.ImperialUnitService

Utility with methods for conversion between imperial and metric 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 input string was not recognized as imperial value

  • tuple

    Length in mm

Examples:

>>> ImperialUnitService.ConvertToMM("4"")
(False, 101.6)
>>> ImperialUnitService.ConvertToMM("0"")
(False, 0.0)
>>> ImperialUnitService.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 input string was not recognized as imperial value

  • tuple

    Weight in kg

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