## XSICollection.Expand

### Description

Expands each item in collection:
- If the item is a group, it replaces the group with its members.
- If the group member was added in branch then it expands the members as though it was a collection item added with the branch flag set.
- If the item is a CollectionItem containing an X3DObject and its ProjectItem.BranchFlag property is set then it traverses the branch and adds each X3DObject in the branch to the collection.

### C# Syntax

    CXSICollection XSICollection.Expand();

### Scripting Syntax

    oReturn = XSICollection.Expand();

### Return Value

XSICollection

### Examples

#### VBScript Example

    Dim oColl             ' object pointer for collection
    Dim oExpColl            ' object pointer for expanded collection
    ' Create the new collection & populate it
    Set oColl = CreateObject( "XSI.Collection" )
    oColl.Add ActiveSceneRoot
    checkContents "oColl", oColl
    ' Expand the collection and save it as a new collection
    LogMessage "----------------"
    Set oRoot = oColl.Item(0)
    oRoot.BranchFlag = siBranch
    Set oExpColl = oColl.Expand
    checkContents "oExpColl", oExpColl
    ' Now start again but this time don't set the branch flag
    LogMessage "----------------"
    oExpColl.RemoveAll
    oRoot.BranchFlag = siNode
    Set oExpColl = oColl.Expand
    checkContents "oExpColl", oExpColl
    '--------------------------------------------------
    function checkContents( in_name, in_coll )
            If in_coll.Count > 0 Then
                    LogMessage in_name & " collection now contains " & in_coll.GetAsText
            Else
                    LogMessage in_name & " collection is empty."
            End If
    end function
    '--------------------------------------------------
    ' Output of above script:
    'INFO : "oColl collection now contains Scene_Root"
    'INFO : "----------------"
    'INFO : "oExpColl collection now contains Scene_Root,Camera_Root,Camera,Camera_Interest,light"
    'INFO : "----------------"
    'INFO : "oExpColl collection now contains Scene_Root"

### See Also

siBranchFlag SelectChildNodes