ClusterElementCollection.ItemsByIndex operator

説明

インデックスによってクラスタエレメント値を設定したり、戻したりします。

Cluster の場合は、要求されたクラスタインデックス(Integer)の関連ジオメトリインデックスの 1D Array に対して、読み取り専用のアクセス与えられます。この配列のサイズは、要求されたインデックスの数に等しくなります。

ClusterProperty の場合は、要求されたクラスタインデックス(Double)のデータを保持する 2D Array を取得したり、設定したりすることができます。最初の次元のサイズは、ClusterProperty に応じて異なります。たとえば、ウェイトマップの場合はエレメントは 1 つしか存在しませんが、エンベロープウェイトマップの場合はサイズはデフォーマの数と等しくなります。2 番目の次元のサイズは、要求されたインデックスの数に等しくなります。

C#構文

// get accessor

Object ClusterElementCollection.get_ItemsByIndex( Object vIndices );

// set accessor

ClusterElementCollection.set_ItemsByIndex( Object vIndices, Object pVal );

パラメータ

パラメータ タイプ 説明
Indices Array エレメントインデックスの配列

1. VBScript の例

'

' This example shows how to use ItemsByIndex on a Cluster

'

dim oRoot, oGrid, oCluster, aValues, iElement

set oRoot = Application.ActiveProject.ActiveScene.Root

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

set oCluster = oGrid.ActivePrimitive.Geometry.AddCluster( _

					siPolygonCluster, "PolygonClusterOnGrid", _

					array(59,60,61))

'Ask for items 0,1,2 of the cluster - which corresponds to

'pnt 59,60,61.  In fact this is the entire cluster.

aValues = oCluster.Elements.ItemsByIndex( Array(0,1,2) )

'Show the ranges of the returned 1-dimensional array

LogMessage "lbound(aValues,1) = " & lbound(aValues,1)

LogMessage "ubound(aValues,1) = " & ubound(aValues,1)

'Print out the geometry indices of the requested cluster

'elements

for iIndex=lbound(aValues,1) to ubound(aValues,1)

	iElement = aValues(iIndex)

	LogMessage "element(" & iIndex & ") = " & _

			oCluster.type & "(" & iElement & ") "

next

' Output of above script:

'INFO : "lbound(aValues,1) = 0"

'INFO : "ubound(aValues,1) = 2"

'INFO : "element(0) = poly(59) "

'INFO : "element(1) = poly(60) "

'INFO : "element(2) = poly(61) "

2. VBScript の例

'

' This example demonstrates how to use ClusterElementCollection.ItemsByIndex to read 

' and write values on a VertexColor ClusterProperty object

'

NewScene ,false

set oSphere = ActiveSceneRoot.AddGeometry("Sphere","MeshSurface")

SelectObj oSphere

'This command will create a complete sample cluster

'and a cluster property called MyVertexColor

CreateVertexColorSupport , "MyVertexColor"

set oClusters = oSphere.ActivePrimitive.Geometry.Clusters

set oVertexColors = oClusters(0).LocalProperties( "MyVertexColor" )

'Get the RGB values on sample point 2 and 3.

'This returns a 2-dimensional array, with the RGBA values

'for the two samples we request.

ElArray = oVertexColors.Elements.ItemsByIndex( Array( 2, 3 ) )

'Set the G value at Sample 2

ElArray( 1, 0 ) = 0.0

'Set the B value at Sample 2

ElArray( 2, 0 ) = 0.5

'Set the R value at Sample 3

ElArray( 0, 1 ) = 0.3

'Set the A value at Sample 3

ElArray( 3, 1 ) = 0.2

'Assign our changes back

oVertexColors.Elements.ItemsByIndex( Array( 2, 3 ) ) = ElArray

'Double check by looking at the entire array

AllRGBAValues = oVertexColors.Elements.Array

logmessage "G Value at Sample 2: " & Round( AllRGBAValues( 1, 2 ), 1 )

logmessage "B Value at Sample 2: " & Round( AllRGBAValues( 2, 2 ), 1 )

logmessage "R Value at Sample 3: " & Round( AllRGBAValues( 0, 3 ), 1 )

logmessage "A Value at Sample 3: " & Round( AllRGBAValues( 3, 3 ), 1 )

'Output of this script:

'INFO : "G Value at Sample 2: 0"

'INFO : "B Value at Sample 2: 0.5"

'INFO : "R Value at Sample 2: 0.3"

'INFO : "A Value at Sample 2: 0.2"