Softimage SDK Programmer's Guide > Plug-in Development > Selection > Finding Out What's Currently Selected >

# Accessing the List of Selected Objects

- The Selection or Selection object/class is a kind of a specialized collection. Each selected object is a member and can be accessed via enumerating or using the Selection.Item or Selection::GetItem property:

    // C++ API
    Selection sel( Application().GetSelection() );
    for( LONG i=0; i<sel.GetCount(); i++ )
    {
    	SIObject obj( sel[i] );
    	Application().LogMessage( obj.GetName() );
    }
    SIObject objByIndex( sel.GetItem(0) ); // Access by index
    SIObject objByName( sel.GetItem(L"grid") ); // Access by name

    // C# (object model)
    CXSIApplication app = new CXSIApplication();
    foreach (CollectionItem itm in app.Selection)
    {
    	app.LogMessage(itm.Name, siSeverity.siInfo);
    }
    SIObject objByIndex = (SIObject)app.Selection[0];		// Access by index
    SIObject objByName = (SIObject)app.Selection["cone"];		// Access by name

    // JScript
    var e = new Enumerator( Selection );
    for( ; !e.atEnd(); !e.moveNext() )
    {
    	var obj = e.item();
    	LogMessage( obj );
    }
    var objByIndex = Selection(0); // Access by index
    var objByName = Selection("grid"); // Access by name

    ' VBScript
    foreach obj in Selection
    	LogMessage obj
    next
    set objByIndex = Selection(0);' Access by index
    set objByName = Selection("grid");' Access by name

    # Python
    for obj in Application.Selection :
    	Application.LogMessage( obj.Name )
    objByIndex = Application.Selection(0) # Access by index
    objByName = Application.Selection("grid") # Access by name

    # Perl
    for ( my $i=0; $i<$Application->Selection->Count; $i++ ) {
    	$Application->LogMessage( $Application->Selection($i)->Name );
    }
    my $objByIndex = $Application->Selection(0);# Access by index
    my $objByName = $Application->Selection("grid");# Access by name

Related Scripting Commands

- GetValue (used with "SelectionList")

- PickElement, PickObject

- SelectFilter, SelectEdgeFilter, SelectObjectFilter, SelectPolygonFilter, SelectSampledPointFilter, SelectVertexFilter

- SetEdgeSelectionFilter, SetPointSelectionFilter, SetPolygonSelectionFilter, SetSampleSelectionFilter