XSICollection.Remove

Description

Removes a single item from the collection. Compare this method to XSICollection.RemoveItems, which removes one or more items at a time and XSICollection.RemoveAll which empties the collection completely.

Scripting Syntax

oReturn = XSICollection.Remove( Item );

Return Value

CollectionItem or kind of ProjectItem removed

Parameters

Parameter Type Description
Item CollectionItem, any kind of ProjectItem or String The new item being removed. This may be a generic object (CollectionItem), a specific type of object (ProjectItem) or an Object Name (string expression).

Examples

VBScript Example

Dim oColl             ' object pointer for collection
Dim sSelList    ' string list for selection
Dim oMember     ' object pointer for members
Dim oNull               ' object pointer for null object
Dim oCollItem   ' object pointer for collection item
Dim sLightName  ' string variable for the camera name 
' Create the new collection & populate it
Set oColl = CreateObject( "XSI.Collection" )
Set oNull = ActiveSceneRoot.AddNull     
oColl.SetAsText oNull & ",Light,Camera"
' Test contents & type
checkContents oColl
For Each oMember In oColl
        checkType oMember
Next
' Now remove some stuff
LogMessage "----------------"
checkType oNull                         ' = project item
oColl.Remove oNull
checkContents oColl
Set oCollItem = oColl.Item( "Camera" )
checkType oCollItem                     ' = collection item
oColl.Remove oCollItem
checkContents oColl
sLightName = "light"                    
checkType sLightName                    ' = string expression
oColl.Remove sLightName
checkContents oColl
'--------------------------------------------------
function checkType( in_object )
        LogMessage in_object & " is a " & TypeName( in_object )
end function
'--------------------------------------------------
function checkContents( in_coll )
        If in_coll.Count > 0 Then
                LogMessage "Collection now contains " & in_coll.GetAsText 
                LogMessage "----------------"
        Else
                LogMessage "Collection is empty."
                LogMessage "----------------"
        End If
end function
'--------------------------------------------------
' Output of above script:
'INFO : "Collection now contains null,light,Camera"
'INFO : "----------------"
'INFO : "null is a Null"
'INFO : "light is a Light"
'INFO : "Camera is a Camera"
'INFO : "----------------"
'INFO : "null is a Null"
'INFO : "Collection now contains light,Camera"
'INFO : "----------------"
'INFO : "Camera is a Camera"
'INFO : "Collection now contains light"
'INFO : "----------------"
'INFO : "light is a String"
'INFO : "Collection is empty."
'INFO : "----------------"

See Also

XSICollection.RemoveAll XSICollection.RemoveItems