NXObjectList Class — NXOpen Python API Reference 12.0.0 documentation

# NXObjectList Class

class `NXOpen.``NXObjectList`

  Bases: `NXOpen.TaggedObject`

  Represents a list of objects.

  To create a new instance of this class, use `NXOpen.Part.CreateObjectList()`

  New in version NX4.0.0.

# Properties

Property | Description
--- | ---
Length | Returns the length of the list
Tag | Returns the Tag for this object.

# Methods

Method | Description
--- | ---
Append | Appends a set of objects to the list
Clear | Clears the entire list without deleting the objects.
ClearIndex | Deletes the item at the index specified.
Erase | Erases the object from the list, but does not delete the object.
FindIndex | Finds the index where the input object appears.
FindItem | Returns the object at the input index.
GetContents | Gets the contents of the entire list
Insert | Inserts an object at the specified location
MoveToBottom | Move object at the specified location to the bottom of the list.
MoveToTop | Move object at the specified location to the top of the list.
SetContents | Sets the contents of the entire list.
Swap | Exchanges the position of two objects inside the list.

# Property Detail

## Length

`NXObjectList.``Length`

  Returns the length of the list

  `-------------------------------------`

  Getter Method

  Signature `Length`

  Returns: |
  Return type: | int

  New in version NX5.0.0.

  License requirements: None.

# Method Detail

## Append

`NXObjectList.``Append`

  Overloaded method Append

  - `Append(objects)`
  - `Append(object)`

  `-------------------------------------`

  Appends a set of objects to the list

  Signature `Append(objects)`

  Parameters: | objects (list of `NXOpen.NXObject`) – items to append

  New in version NX4.0.0.

  License requirements: None.

  `-------------------------------------`

  Appends an object to the list

  Signature `Append(object)`

  Parameters: | object (`NXOpen.NXObject`) – item to append

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

## Clear

`NXObjectList.``Clear`

  Overloaded method Clear

  - `Clear()`
  - `Clear(deleteOption)`

  `-------------------------------------`

  Clears the entire list without deleting the objects. The caller is responsible for accounting for these objects. If they are not used or deleted by the time the part is closed (in other words, leaked) an error will occur

  Signature `Clear()`

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

  Clears the entire list

  Signature `Clear(deleteOption)`

  Parameters: | deleteOption (`NXOpen.ObjectListDeleteOption`) – whether to delete the objects when removing them

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

## ClearIndex

`NXObjectList.``ClearIndex`

  Deletes the item at the index specified.

  The size of the list does * not change, but the item at this index is set to NULL.

  Signature `ClearIndex(deleteIdx)`

  Parameters: | deleteIdx (int) – index of item to be deleted

  New in version NX4.0.0.

  License requirements: None.

## Erase

`NXObjectList.``Erase`

  Overloaded method Erase

  - `Erase(index)`
  - `Erase(index, deleteOption)`
  - `Erase(obj)`
  - `Erase(obj, deleteOption)`

  `-------------------------------------`

  Erases the object from the list, but does not delete the object. The list is shifted so that there isn’t a null where the object used to be.

  Signature `Erase(index)`

  Parameters: | index (int) – index of item to be removed from the list

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

  Erases the object at the given position from the list. The list is shifted so that there isn’t a null where the object used to be.

  Signature `Erase(index, deleteOption)`

  Parameters:

  - index (int) – index of item to be removed from the list
  - deleteOption (`NXOpen.ObjectListDeleteOption`) – whether to delete the object

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

  Erases the object from the list, but does not delete the object. The list is shifted so that there isn’t a null where the object used to exist.

  Signature `Erase(obj)`

  Parameters: | obj (`NXOpen.NXObject`) – object to be removed from the list

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

  Erases the object from the list. The list is shifted so that there isn’t a null where the object used to exist.

  Signature `Erase(obj, deleteOption)`

  Parameters:

  - obj (`NXOpen.NXObject`) – object to be removed from the list
  - deleteOption (`NXOpen.ObjectListDeleteOption`) – whether to delete the object

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

## FindIndex

`NXObjectList.``FindIndex`

  Finds the index where the input object appears.

  If it does not appear, * -1 is returned.

  Signature `FindIndex(obj)`

  Parameters: | obj (`NXOpen.NXObject`) – Object to find index for
  Returns: | index of input object, -1 if not on list
  Return type: | int

  New in version NX4.0.0.

  License requirements: None.

## FindItem

`NXObjectList.``FindItem`

  Returns the object at the input index.

  May be NULL.

  Signature `FindItem(index)`

  Parameters: | index (int) – index of object to return
  Returns: | object found at input index
  Return type: | `NXOpen.NXObject`

  New in version NX4.0.0.

  License requirements: None.

## GetContents

`NXObjectList.``GetContents`

  Gets the contents of the entire list

  Signature `GetContents()`

  Returns: | The list contents
  Return type: | list of `NXOpen.NXObject`

  New in version NX5.0.0.

  License requirements: None.

## Insert

`NXObjectList.``Insert`

  Inserts an object at the specified location

  Signature `Insert(location, object)`

  Parameters:

  - location (int) – location at which to insert the object
  - object (`NXOpen.NXObject`) – object to be inserted

  New in version NX5.0.0.

  License requirements: None.

## MoveToBottom

`NXObjectList.``MoveToBottom`

  Move object at the specified location to the bottom of the list.

  Signature `MoveToBottom(index)`

  Parameters: | index (int) – location of the item

  New in version NX10.0.0.

  License requirements: None.

## MoveToTop

`NXObjectList.``MoveToTop`

  Move object at the specified location to the top of the list.

  Signature `MoveToTop(index)`

  Parameters: | index (int) – location of the item

  New in version NX10.0.0.

  License requirements: None.

## SetContents

`NXObjectList.``SetContents`

  Sets the contents of the entire list.

  This overwrites the previous contents of this list, but does not delete any objects that were originally on the list.

  Signature `SetContents(objects)`

  Parameters: | objects (list of `NXOpen.NXObject`) – The list contents

  New in version NX5.0.0.

  License requirements: None.

## Swap

`NXObjectList.``Swap`

  Overloaded method Swap

  - `Swap(index1, index2)`
  - `Swap(object1, object2)`

  `-------------------------------------`

  Exchanges the position of two objects inside the list. The first object is placed where the second used to be, and second object where the first used to be.

  Signature `Swap(index1, index2)`

  Parameters:

  - index1 (int) – location of the first item
  - index2 (int) – location of the second item

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`

  Exchanges the position of two objects inside the list. The first object is placed where the second used to be, and second object where the first used to be.

  Signature `Swap(object1, object2)`

  Parameters:

  - object1 (`NXOpen.NXObject`) – first item
  - object2 (`NXOpen.NXObject`) – second item

  New in version NX5.0.0.

  License requirements: None.

  `-------------------------------------`