Sets or returns cluster element values by index.
In the case of a Clusters this provides
read-only access to a 1-dimensional Array of the associated geometry indices
(Integers) for the requested
cluster indices. The size of this array is the same as the number
of requested indices.
In the case of a ClusterProperty, this allows you to get
or set a 2-dimensional Array
containing the data on the requested cluster indices (Doubles). The size of the first dimension
depends on the ClusterProperty. For example for a weight map there
is only 1 element but for an envelope weight map the size is equal
to the number of deformers. The size of the second dimension is the
same as the number of requested indices.
// get accessor Object ClusterElementCollection.get_ItemsByIndex( Object vIndices ); // set accessor ClusterElementCollection.set_ItemsByIndex( Object vIndices, Object pVal ); |
Parameter | Type | Description |
---|---|---|
Indices | Array | Array of element indicies |
' ' 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) " |
' ' 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" |