OCC.UnitsAPI module¶
The UnitsAPI global functions are used toconvert a value from any unit into another unit.PrinciplesConversion is executed among three unit systems:- the SI System- the user’s Local System- the user’s Current System.The SI System is the standard international unitsystem. It is indicated by SI in the synopses ofthe UnitsAPI functions.The MDTV System corresponds to the SIinternational standard but the length unit and allits derivatives use millimeters instead of the meters.Both systems are proposed by Open CASCADE;the SI System is the standard option. Byselecting one of these two systems, the userdefines his Local System through theSetLocalSystem function. The Local System isindicated by LS in the synopses of the UnitsAPI functions.The user’s Local System units can be modified inthe working environment. The user defines hisCurrent System by modifying its units throughthe SetCurrentUnit function. The CurrentSystem is indicated by Current in the synopsesof the UnitsAPI functions.
-
class
SwigPyIterator
(*args, **kwargs)¶ Bases:
object
-
advance
()¶
-
copy
()¶
-
decr
()¶
-
distance
()¶
-
equal
()¶
-
incr
()¶
-
next
()¶
-
previous
()¶
-
thisown
¶ The membership flag
-
value
()¶
-
-
new_instancemethod
(func, inst, cls)¶
-
register_handle
(handle, base_object)¶ Inserts the handle into the base object to prevent memory corruption in certain cases
-
class
unitsapi
¶ Bases:
object
-
static
AnyFromLS
()¶ - Converts the local system units value to the local unit value. Example: AnyFromLS(25.4,’in.’) returns 1. if the LocalSystem is MDTV. Note: aUnit is also used to identify the type of physical quantity to convert.
Parameters: - aData (float) –
- aUnit (char *) –
Return type:
-
static
AnyFromSI
()¶ - Converts the SI system units value to the local unit value. Example: AnyFromSI(0.0254,’in.’) returns 0.001 Note: aUnit is also used to identify the type of physical quantity to convert.
Parameters: - aData (float) –
- aUnit (char *) –
Return type:
-
static
AnyToAny
()¶ - Converts the local unit value to another local unit value. Example: AnyToAny(0.0254,’in.’,’millimeter’) returns 1. ;
Parameters: - aData (float) –
- aUnit1 (char *) –
- aUnit2 (char *) –
Return type:
-
static
AnyToLS
()¶ - Converts the local unit value to the local system units value. Example: AnyToLS(1.,’in.’) returns 25.4 if the LocalSystem is MDTV.
Parameters: - aData (float) –
- aUnit (char *) –
Return type: - Converts the local unit value to the local system units value. and gives the associated dimension of the unit
Parameters: - aData (float) –
- aUnit (char *) –
- aDim (Handle_Units_Dimensions &) –
Return type:
-
static
AnyToSI
()¶ - Converts the local unit value to the SI system units value. Example: AnyToSI(1.,’in.’) returns 0.0254
Parameters: - aData (float) –
- aUnit (char *) –
Return type: - Converts the local unit value to the SI system units value. and gives the associated dimension of the unit
Parameters: - aData (float) –
- aUnit (char *) –
- aDim (Handle_Units_Dimensions &) –
Return type:
-
static
Check
()¶ - Checks the coherence between the quantity <aQuantity> and the unit <aUnits> in the current system and returns False when it’s WRONG.
Parameters: - aQuantity (char *) –
- aUnit (char *) –
Return type:
-
static
CurrentFromAny
()¶ - Converts the aData value expressed in the unit aUnit, into the current unit for the working environment, as defined for the physical quantity aQuantity by the last call to the SetCurrentUnit function.
Parameters: - aData (float) –
- aQuantity (char *) –
- aUnit (char *) –
Return type:
-
static
CurrentFromLS
()¶ - Converts the local system units value to the current unit value. Example: CurrentFromLS(1000.,’LENGTH’) returns 1. if current length unit is meter and LocalSystem is MDTV.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
static
CurrentFromSI
()¶ - Converts the SI system units value to the current unit value. Example: CurrentFromSI(0.001,’LENGTH’) returns 1 if current length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
static
CurrentToAny
()¶ - Converts the aData value expressed in the current unit for the working environment, as defined for the physical quantity aQuantity by the last call to the SetCurrentUnit function, into the unit aUnit.
Parameters: - aData (float) –
- aQuantity (char *) –
- aUnit (char *) –
Return type:
-
static
CurrentToLS
()¶ - Converts the current unit value to the local system units value. Example: CurrentToLS(1.,’LENGTH’) returns 1000. if the current length unit is meter and LocalSystem is MDTV.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
static
CurrentToSI
()¶ - Converts the current unit value to the SI system units value. Example: CurrentToSI(1.,’LENGTH’) returns 0.001 if current length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
static
CurrentUnit
()¶ - Returns the current unit dimension <aUnit> from the unit quantity <aQuantity>.
Parameters: aQuantity (char *) – Return type: char *
-
static
DimensionAmountOfSubstance
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionElectricCurrent
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionLength
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionLess
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionLuminousIntensity
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionMass
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionPlaneAngle
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionSolidAngle
()¶ - Returns the basic dimensions.
Return type: Handle_Units_Dimensions
-
static
DimensionThermodynamicTemperature
()¶ Return type: Handle_Units_Dimensions
-
static
DimensionTime
()¶ Return type: Handle_Units_Dimensions
-
static
Dimensions
()¶ - return the dimension associated to the quantity
Parameters: aQuantity (char *) – Return type: Handle_Units_Dimensions
-
static
LSToSI
()¶ - Converts the local system units value to the SI system unit value. Example: LSToSI(1.,’LENGTH’) returns 0.001 if the local system length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
static
LocalSystem
()¶ - Returns the current local system units.
Return type: UnitsAPI_SystemUnits
-
static
Reload
()¶ Return type: void
-
static
SIToLS
()¶ - Converts the SI system unit value to the local system units value. Example: SIToLS(1.,’LENGTH’) returns 1000. if the local system length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
static
Save
()¶ - saves the units in the file .CurrentUnits of the directory pointed by the CSF_CurrentUnitsUserDefaults environment variable.
Return type: void
-
static
SetCurrentUnit
()¶ - Sets the current unit dimension <aUnit> to the unit quantity <aQuantity>. Example: SetCurrentUnit(‘LENGTH’,’millimeter’)
Parameters: - aQuantity (char *) –
- aUnit (char *) –
Return type: void
-
static
SetLocalSystem
()¶ - Sets the local system units. Example: SetLocalSystem(UnitsAPI_MDTV)
Parameters: aSystemUnit (UnitsAPI_SystemUnits) – default value is UnitsAPI_SI Return type: void
-
thisown
¶ The membership flag
-
static
-
unitsapi_AnyFromLS
()¶ - Converts the local system units value to the local unit value. Example: AnyFromLS(25.4,’in.’) returns 1. if the LocalSystem is MDTV. Note: aUnit is also used to identify the type of physical quantity to convert.
Parameters: - aData (float) –
- aUnit (char *) –
Return type:
-
unitsapi_AnyFromSI
()¶ - Converts the SI system units value to the local unit value. Example: AnyFromSI(0.0254,’in.’) returns 0.001 Note: aUnit is also used to identify the type of physical quantity to convert.
Parameters: - aData (float) –
- aUnit (char *) –
Return type:
-
unitsapi_AnyToAny
()¶ - Converts the local unit value to another local unit value. Example: AnyToAny(0.0254,’in.’,’millimeter’) returns 1. ;
Parameters: - aData (float) –
- aUnit1 (char *) –
- aUnit2 (char *) –
Return type:
-
unitsapi_AnyToLS
()¶ - Converts the local unit value to the local system units value. Example: AnyToLS(1.,’in.’) returns 25.4 if the LocalSystem is MDTV.
Parameters: - aData (float) –
- aUnit (char *) –
Return type: - Converts the local unit value to the local system units value. and gives the associated dimension of the unit
Parameters: - aData (float) –
- aUnit (char *) –
- aDim (Handle_Units_Dimensions &) –
Return type:
-
unitsapi_AnyToSI
()¶ - Converts the local unit value to the SI system units value. Example: AnyToSI(1.,’in.’) returns 0.0254
Parameters: - aData (float) –
- aUnit (char *) –
Return type: - Converts the local unit value to the SI system units value. and gives the associated dimension of the unit
Parameters: - aData (float) –
- aUnit (char *) –
- aDim (Handle_Units_Dimensions &) –
Return type:
-
unitsapi_Check
()¶ - Checks the coherence between the quantity <aQuantity> and the unit <aUnits> in the current system and returns False when it’s WRONG.
Parameters: - aQuantity (char *) –
- aUnit (char *) –
Return type:
-
unitsapi_CurrentFromAny
()¶ - Converts the aData value expressed in the unit aUnit, into the current unit for the working environment, as defined for the physical quantity aQuantity by the last call to the SetCurrentUnit function.
Parameters: - aData (float) –
- aQuantity (char *) –
- aUnit (char *) –
Return type:
-
unitsapi_CurrentFromLS
()¶ - Converts the local system units value to the current unit value. Example: CurrentFromLS(1000.,’LENGTH’) returns 1. if current length unit is meter and LocalSystem is MDTV.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
unitsapi_CurrentFromSI
()¶ - Converts the SI system units value to the current unit value. Example: CurrentFromSI(0.001,’LENGTH’) returns 1 if current length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
unitsapi_CurrentToAny
()¶ - Converts the aData value expressed in the current unit for the working environment, as defined for the physical quantity aQuantity by the last call to the SetCurrentUnit function, into the unit aUnit.
Parameters: - aData (float) –
- aQuantity (char *) –
- aUnit (char *) –
Return type:
-
unitsapi_CurrentToLS
()¶ - Converts the current unit value to the local system units value. Example: CurrentToLS(1.,’LENGTH’) returns 1000. if the current length unit is meter and LocalSystem is MDTV.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
unitsapi_CurrentToSI
()¶ - Converts the current unit value to the SI system units value. Example: CurrentToSI(1.,’LENGTH’) returns 0.001 if current length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
unitsapi_CurrentUnit
()¶ - Returns the current unit dimension <aUnit> from the unit quantity <aQuantity>.
Parameters: aQuantity (char *) – Return type: char *
-
unitsapi_DimensionAmountOfSubstance
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionElectricCurrent
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionLength
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionLess
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionLuminousIntensity
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionMass
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionPlaneAngle
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionSolidAngle
()¶ - Returns the basic dimensions.
Return type: Handle_Units_Dimensions
-
unitsapi_DimensionThermodynamicTemperature
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_DimensionTime
()¶ Return type: Handle_Units_Dimensions
-
unitsapi_Dimensions
()¶ - return the dimension associated to the quantity
Parameters: aQuantity (char *) – Return type: Handle_Units_Dimensions
-
unitsapi_LSToSI
()¶ - Converts the local system units value to the SI system unit value. Example: LSToSI(1.,’LENGTH’) returns 0.001 if the local system length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
unitsapi_LocalSystem
()¶ - Returns the current local system units.
Return type: UnitsAPI_SystemUnits
-
unitsapi_Reload
()¶ Return type: void
-
unitsapi_SIToLS
()¶ - Converts the SI system unit value to the local system units value. Example: SIToLS(1.,’LENGTH’) returns 1000. if the local system length unit is millimeter.
Parameters: - aData (float) –
- aQuantity (char *) –
Return type:
-
unitsapi_Save
()¶ - saves the units in the file .CurrentUnits of the directory pointed by the CSF_CurrentUnitsUserDefaults environment variable.
Return type: void
-
unitsapi_SetCurrentUnit
()¶ - Sets the current unit dimension <aUnit> to the unit quantity <aQuantity>. Example: SetCurrentUnit(‘LENGTH’,’millimeter’)
Parameters: - aQuantity (char *) –
- aUnit (char *) –
Return type: void
-
unitsapi_SetLocalSystem
()¶ - Sets the local system units. Example: SetLocalSystem(UnitsAPI_MDTV)
Parameters: aSystemUnit (UnitsAPI_SystemUnits) – default value is UnitsAPI_SI Return type: void