## SelectNeighborObj

### Introduced

v1.0

### Description

Selects parent, child, or sibling objects. You should consider using NavigateNode if you do not want to select the elements.

### Scripting Syntax

    SelectNeighborObj( [InputObjs], [NavigDirection], [HierarchyLevel], [AddToSelection] );

### Parameters

Parameter | Type | Description
--- | --- | ---
InputObjs | String | List of objects. Default Value: Current selection.
NavigDirection | Integer | Direction to navigate Default Value: 0
Possible Values: | Description:
0 | Select parent
1 | Select child
2 | Select previous sibling
3 | Select next sibling
HierarchyLevel | String | Specifies how to select objects in a hierarchy. Default Value: "ASITIS"
Possible Values: | Description:
ASITIS | Select the object as it is.
NODE | Select the object.
BRANCH | Select the object and its children.
TREE | Select the entire hierarchy of objects.
MODEL | Select the model and the hierarchy of objects.
AddToSelection | Boolean | True to add to the selection, False to replace the selection. Default Value: False

### Examples

#### VBScript Example

    ' Given this hierarchy:

    '

    ' cube

    '   cube1

    '     cube2

    '     sphere

    '     cone

    '

    ' the following example will invoke SelectNeighborObj many times

    ' each time selecting a different part of the hierarchy.

    NewScene

    CreatePrim "Cube", "MeshSurface"

    SetValue "cube.cube.length", 12

    CreatePrim "Cube", "MeshSurface"

    SetValue "cube1.cube.length", 10

    CopyPaste "cube1", , "cube", 1

    CreatePrim "Cube", "MeshSurface"

    CopyPaste "cube2", , "cube1", 1

    CreatePrim "Sphere", "MeshSurface"

    CopyPaste "sphere", , "cube1", 1

    CreatePrim "Cone", "MeshSurface"

    CopyPaste "cone", , "cube1", 1

    MsgBox "Let's now select the parent of cube2 (cube1)"

    SelectNeighborObj "cube2"

    MsgBox "Let's now select the first child of cube1 (cube2)"

    SelectNeighborObj "cube1", 1

    MsgBox "Let's now select the next sibling of sphere (cone)"

    SelectNeighborObj "sphere", 3

    MsgBox "Let's now add the parent of cube2 (cube1) to the selection"

    SelectNeighborObj "cube2", , , True

    MsgBox "Let's now select the parent of cube (scene root)"

    SelectNeighborObj "cube"

    MsgBox "Let's now go through all direct children of the scene root and log its name"

    dim obj, first, child

    ' get first child (Camera_Root) of the scene root

    SelectObj "Scene_Root"

    set obj = GetValue( "SelectionList" )

    SelectNeighborObj obj(0), 1

    set first = GetValue( "SelectionList" )

    ' lets log the name of that first child

    LogMessage "First child of " & obj(0) & " is " & first

    ' get sibling of that object (light)

    SelectNeighborObj first, 3	' get next sibling

    set child = GetValue( "SelectionList" )

    ' log its name and get new sibling

    ' and loop until no more sibling

    do until child = first

    	LogMessage "Next sibling is " & child

    	SelectNeighborObj child, 3		' get next sibling

    	set child = GetValue( "SelectionList" )

    loop

    ' The log of the example above should be :

    'INFO : "First child of Scene_Root is Camera_Root"

    'INFO : "Next sibling is light"

    'INFO : "Next sibling is cube"

### See Also

NavigateNode