Softimage SDK Programmer's Guide > Script Development > Working with Arrays (and Other Collections) in Softimage > Collections vs. Arrays >

# Creating and Adding to Collections

You can create a blank collection and add items (CollectionItem) to it with the Add method, or by using the Value property of the CollectionItem object. You can also create a populated collection by using wildcards.

## To create an empty collection

To create a collection in Softimage, you can use CreateObject (a VBScript command) to create a generic XSICollection object:

    ' Create XSI.Collection object
    Set oCollection = CreateObject( "XSI.Collection" )

## To add items to a collection with the Add method

To add an item to a collection, use the collection's Add method. For example, if oCollection is a collection:

    oCollection.Add "CameraInterest"

## To add items to a collection with the CollectionItem.Value property

You can also create a CollectionItem and set its value. For example, if you already created oCollection:

    set oItem = CreateObject( "XSI.CollectionItem" )
    oItem.value = "Camera"
    oCollection.Add oItem

## To create a populated collection with wildcards

    Set oLayers = CreateObject("XSI.Collection")
    oLayers.Items = "Layers.List.*"
    For Each oLayer In oLayers
       LogMessage oLayers.Name
    Next