## InvertSelection

### Introduced

v1.0

### Description

Deselects the elements that are currently selected, and selects the elements that are selected.
Note: If the SelectionList argument contains an error, the command fails.

### Scripting Syntax

    InvertSelection( [SelFilter], [CheckComponentVisibility], [CheckObjectSelectability] );

### Parameters

Parameter | Type | Description
--- | --- | ---
SelFilter | FilterConstant | Selection filter that specifies what type of elements to select. Default Value: Current selection filter
CheckComponentVisibility | siComponentVisibilityMode | Specifies whether the command should apply to visible components only. Default Value: siIgnoreComponentVisibility
Possible Values: | Description:
siIgnoreComponentVisibility | The command will ignore component visibility
siCheckComponentVisibility | The command will apply to visible components only
CheckObjectSelectability | Boolean | Specifies whether to select objects that marked as unselectable. Default Value: False
Possible Values: | Description:
False | Select objects even if they are marked as unselectable.
True | Do not select objects if they are marked as unselectable.

### Examples

#### 1. VBScript Example

    NewScene
    ' Create some objects and an extra light to play with
    CreatePrim "Cube", "MeshSurface"
    Translate , -6, -0.995037190209989, 9.95037190209989E-02, siAbsolute, siView, siObj, siXYZ, True, , , , , , , , , 0
    Scale , 0.46615087040619, 0.46615087040619, 0.46615087040619, siRelative, siGlobal, siObj, siXYZ, , , , , , , , 0
    CreatePrim "Sphere", "MeshSurface"
    Translate , 6, -0.995037190209989, 9.95037190209989E-02, siAbsolute, siView, siObj, siXYZ, True, , , , , , , , , 0
    GetPrimLight "Infinite.Preset", "Infinite"
    SelectObj "Cube,Infinite"
    ' Deselect all selected objects, and select all unselected objects
    PrintSelection
    InvertSelection "object"
    PrintSelection
    ' Note that when you use a filter, everything that does not match the filter is unselected
    ' For example, this command inverts the selection status of all the lights, and unselects
    ' all other elements in the scene.
    InvertSelection "light"
    PrintSelection
    ' Invert the selection of some components
    SetSelFilter "Vertex"
    SelectGeometryComponents "cube.pnt[3,4]"
    PrintSelection
    InvertSelection "point"
    PrintSelection
    Sub PrintSelection
            msg = "Selection:"
            if Selection.count = 0 then
                    msg = msg & " <empty>"
            else
                    for each obj in Selection
                            msg = msg & " " & obj
                    next
            end if
            logmessage msg
    End Sub

#### 2. VBScript Example

    NewScene
    ' Create a sphere, hide some polygons
    CreatePrim "Sphere", "MeshSurface"
    ActivatePolygonSelTool
    SelectGeometryComponents "sphere.poly[4,12,20,28,36,44,52,60]"
    ToggleVisibility
    ' Select the right half of the sphere.
    SelectGeometryComponents "sphere.poly[16-47]"
    ' Invert the poly selection, ignoring the fact that some of the polys are hidden
    MsgBox "Will now InvertSelection ignoring component visibility..."
    InvertSelection , siIgnoreComponentVisibility
    MsgBox "Notice some of the hidden polygons are selected"
    ' Invert the poly selection again, taking into account the fact that some of the polys are hidden
    MsgBox "Will now InvertSelection again, but checking component visibility..."
    InvertSelection , siCheckComponentVisibility
    MsgBox "Notice no hidden polygons are selected"