SIObjectCollection.Item operator

説明

インデックスまたはキーによってコレクションのメンバを設定したり、戻したりします。コレクションが空の場合、このプロパティは "Nothing" を戻すので、エラーの捕捉に使用できます。

注: このコレクションの取得に使用したプロパティがオペレータに準拠している場合は、このプロパティはオペレータにのみ準拠します。

C#構文

// get accessor

SIObject SIObjectCollection.get_Item( Object idx );

パラメータ

パラメータ タイプ 説明
key String または Integer コレクションのメンバの位置または名前を指定する表現。

注: コレクション項目を名前で識別するには、SIObject.Name 値をキーとして使用します。ただし、ParameterCollection で作業していない場合に限ります。Parameter とともに、Parameter.ScriptName 値を使用することもできます。たとえば、oConstraints.Item("Direction Cns")は機能しますが、oConstraints.Item("dircns")は機能しません。

1. VBScript の例

' Set up the example using a mesh grid, cube, cone, and a nurbs cube:

set oRoot = activesceneroot

oRoot.addgeometry "grid", "meshsurface"

oRoot.addgeometry "cube", "meshsurface"

oRoot.addgeometry "cone", "meshsurface"

oRoot.addgeometry "cube", "nurbssurface"

set oGeoms = oRoot.findchildren( ,,siGeometryFamily)

logmessage "The collection of geometry from the root is a " & typename( oGeoms ) 

logmessage "There are " & oGeoms.count & " geometry objects under the root." 

logmessage ""

' Use error trapping ( if you get an empty collection, you will 

' see this error message: 'ERROR : "Object required: 'oCube1'" )

if typename( oGeoms ) = "Nothing" then

	logmessage "Collection is empty"

else 

	logmessage "Collection has " & oGeoms.count & " member(s)."

	for i = 0 to oGeoms.count - 1

		set oGeomItem = oGeoms.item(i)

		logmessage oGeomItem.name & " is a " & oGeomItem.type & " " & typename( oGeomItem )

		set oGeomItem = Nothing

	next

end if

' Output of above script is:

'INFO : "The collection of geometry from the root is a X3DObjectCollection"

'INFO : "There are 4 geometry objects under the root."

'INFO : ""

'INFO : "Collection has 4 member(s)."

'INFO : "grid is a polymsh X3DObject"

'INFO : "cube is a polymsh X3DObject"

'INFO : "cone is a polymsh X3DObject"

'INFO : "cube1 is a surfmsh X3DObject"

2. VBScript の例

'VBScript example

set oRoot = Application.ActiveProject.ActiveScene.Root

set oGrid = oRoot.AddGeometry("Grid","MeshSurface")

set oCluster = oGrid.ActivePrimitive.Geometry.AddCluster(siPolygonCluster, "PolygonClusterOnGrid", array(59,60,61))

for i = 0 to (oCluster.Elements.Count - 1)

	LogMessage "Element(" & i & ") = " & oCluster.Elements(i)

next