XSICollection.RemoveItems

XSICollection.RemoveItems

説明

1 つまたは複数の項目をコレクションから削除します。このメソッドを、XSICollection.Remove(一度に単一の項目のみ削除)や XSICollection.RemoveAll(コレクションを完全に空にする)と比較してください。

C#構文

Object XSICollection.RemoveItems( Object in_newVal );

スクリプト構文

oReturn = XSICollection.RemoveItems( Items );

戻り値

削除された項目(XSICollection

パラメータ

パラメータ タイプ 説明
Items XSICollectionArrayまたはobject name 削除する項目

1. VBScript の例

Dim oColl1		' object pointer for first collection

Dim oColl2		' object pointer for second collection

Dim aItems		' array of items to add all at once

' Create the first collection & populate it 

Set oColl1 = CreateObject( "XSI.Collection" )

oColl1.SetAsText "Camera,Light"

checkContents oColl1

' Create the second collection & populate it 

LogMessage "----------------"

Set oColl2 = CreateObject( "XSI.Collection" )

oColl2.AddItems oColl1

' Since the Unique property hasn't been set to True, we can 

' add another instance of the camera to the collection

oColl2.Add "Camera"

checkContents oColl2

' Remove the light and one instance of the camera

LogMessage "----------------"

oColl2.RemoveItems oColl1

checkContents oColl2

'--------------------------------------------------

function checkContents( in_coll )

	If in_coll.Count > 0 Then

		LogMessage "Collection now contains " & in_coll.GetAsText 

	Else

		LogMessage "Collection is empty."

	End If

end function

'--------------------------------------------------

' Output of above script:

'INFO : "Collection now contains Camera,light"

'INFO : "----------------"

'INFO : "Collection now contains Camera,light,Camera"

'INFO : "----------------"

'INFO : "Collection now contains Camera"

2. JScript の例

/*

	This example demonstrates how to split a collection into 2

*/

NewScene( null, false );

// ----------------------------------------------------

// Create a collection & populate it

var oFolks = new ActiveXObject( "XSI.Collection" );

var oSammy = ActiveSceneRoot.AddNull( "Sammy" );

oFolks.Add( oSammy );

var oRoger = ActiveSceneRoot.AddNull( "Roger" );

oFolks.Add( oRoger );

var oBelinda = ActiveSceneRoot.AddNull( "Belinda" );

oFolks.Add( oBelinda );

var oAgnes = ActiveSceneRoot.AddNull( "Agnes" );

oFolks.Add( oAgnes );

// This will tell us that Sammy, Roger, Belinda, and Agnes

// are all members of the folks collection

checkContents( oFolks, "oFolks" );

Application.LogMessage( "----------------" );

// ----------------------------------------------------

// Remove Sammy and Roger and save the removed ones

// in another collection, leaving the original with the

// two women and the new collection with two men

var oMen = oFolks.RemoveItems( "Sammy,Roger" );

checkContents( oFolks, "oFolks" );

checkContents( oMen, "oMen" );

//--------------------------------------------------

function checkContents( in_coll, in_id )

{

	if ( in_coll.Count > 0 )

	{

		LogMessage( in_id + " collection contains: " + in_coll.GetAsText() );

	}

	else

	{

		Application.LogMessage( in_id + " collection is empty." );

	}

}

//--------------------------------------------------

// Output of above script:

//INFO : "oFolks collection contains: Sammy,Roger,Belinda,Agnes"

//INFO : "----------------"

//INFO : "oFolks collection contains: Belinda,Agnes"

//INFO : "oMen collection contains: Sammy,Roger"

関連項目

XSICollection.Unique XSICollection.Remove XSICollection.RemoveAll