UnitCollection Class — NXOpen Python API Reference 12.0.0 documentation

# UnitCollection Class

class `NXOpen.``UnitCollection`

  Bases: `object`

  Provides methods for manipulating the units in a part

  To obtain an instance of this class, refer to `NXOpen.BasePart`

  New in version NX4.0.0.

# Methods

Method | Description
--- | ---
Convert | Convert a value from one unit of measure to another
FindObject | Finds the `Unit` with the given name.
GetBase | Find the base unit type for a given measure.
GetDefaultDataEntryUnits | Get the choice of default set of units for data entry in the given part
GetDefaultObjectInformationUnits | Get the choice of default set of units for object information in the given part
GetMeasureTypes | Finds the unit types that are available for a given measure
GetMeasures | Finds the list of different types of measures available in the system.
SetDefaultDataEntryUnits | Set a choice of default set of units for data entry in the given part.
SetDefaultObjectInformationUnits | Set a choice of default set of units for object information in the given part

# Enumerations

UnitCollectionUnitDefaults Enumeration | Specifies a set of units to be used as defaults for data entry or object information For each measure, a unit type will be selected that matches the specified choice.

# Method Detail

## Convert

`UnitCollection.``Convert`

  Convert a value from one unit of measure to another

  Signature `Convert(initialUnitType, targetUnitType, initialValue)`

  Parameters:

  - initialUnitType (`NXOpen.Unit`) – initial measurement unit
  - targetUnitType (`NXOpen.Unit`) – target measurement unit
  - initialValue (float) –

  Returns: |
  Return type: | float

  New in version NX4.0.0.

  License requirements: None.

## FindObject

`UnitCollection.``FindObject`

  Finds the `Unit` with the given name.

  Signature `FindObject(name)`

  Parameters: | name (str) – Name to be found
  Returns: | Unit found
  Return type: | `NXOpen.Unit`

  New in version NX4.0.0.

  License requirements: None.

## GetBase

`UnitCollection.``GetBase`

  Find the base unit type for a given measure.

  The returned unit type depends on whether the part is an inch or millimeter part.

  Signature `GetBase(measureName)`

  Parameters: | measureName (str) – the type of measure
  Returns: | base unit
  Return type: | `NXOpen.Unit`

  New in version NX4.0.0.

  License requirements: None.

## GetDefaultDataEntryUnits

`UnitCollection.``GetDefaultDataEntryUnits`

  Get the choice of default set of units for data entry in the given part

  Signature `GetDefaultDataEntryUnits()`

  Returns: |
  Return type: | `NXOpen.UnitCollectionUnitDefaults`

  New in version NX12.0.0.

  License requirements: None.

## GetDefaultObjectInformationUnits

`UnitCollection.``GetDefaultObjectInformationUnits`

  Get the choice of default set of units for object information in the given part

  Signature `GetDefaultObjectInformationUnits()`

  Returns: |
  Return type: | `NXOpen.UnitCollectionUnitDefaults`

  New in version NX12.0.0.

  License requirements: None.

## GetMeasureTypes

`UnitCollection.``GetMeasureTypes`

  Finds the unit types that are available for a given measure

  Signature `GetMeasureTypes(measureName)`

  Parameters: | measureName (str) – the type of measure
  Returns: | Array of units for a given measurement type
  Return type: | list of `NXOpen.Unit`

  New in version NX4.0.0.

  License requirements: None.

## GetMeasures

`UnitCollection.``GetMeasures`

  Finds the list of different types of measures available in the system.

  Types of measures include length, area and volume

  Signature `GetMeasures()`

  Returns: | Array of names of measures
  Return type: | list of str

  New in version NX4.0.0.

  License requirements: None.

## SetDefaultDataEntryUnits

`UnitCollection.``SetDefaultDataEntryUnits`

  Set a choice of default set of units for data entry in the given part.

  Signature `SetDefaultDataEntryUnits(defaults)`

  Parameters: | defaults (`NXOpen.UnitCollectionUnitDefaults`) –

  New in version NX12.0.0.

  License requirements: None.

## SetDefaultObjectInformationUnits

`UnitCollection.``SetDefaultObjectInformationUnits`

  Set a choice of default set of units for object information in the given part

  Signature `SetDefaultObjectInformationUnits(defaults)`

  Parameters: | defaults (`NXOpen.UnitCollectionUnitDefaults`) –

  New in version NX12.0.0.

  License requirements: None.