GridData.Data operator

Introduced

v4.0

Description

Returns or sets the entire 2-dimensional array of cell data. The data is represented in a 2-dimensional SAFEARRAY of Variants.

The first dimension is the column and the second dimension is the row.

Provided that the GridData.RowCount and GridData.ColumnCount have been previously set, it is also possible to set the property with a 1-dimensional SAFEARRAY or with a JScript Array. In this case the array must contain Row * Column items and the data is interpreted to be ordered row by row rather than column by column.

Using this property it is possible to manipulate data from any Softimage method which returns a 2-dimensional array, for example ClusterProperty data. This is demonstrated in one of the examples.

C# Syntax

// get accessor
Object rtn = GridData.Data;
// set accessor
GridData.Data = Object;

Examples

1. VBScript Example

'Demonstrate setting data with the GridData.Data method
set oGridData = XSIFactory.CreateGridData
'Create an array with 2 columns
'and 4 rows.  
dim mydata( 1, 3 )
'Initialize the data (we leave one row empty)
mydata( 0, 0 ) = 12000
mydata( 1, 0 ) = "Col1Row0"
mydata( 0, 1 ) = "Col0Row1"
mydata( 1, 1 ) = 4.567
mydata( 0, 3 ) = "Col0Row3"
mydata( 1, 3 ) = Now 	'Store current time
'It is not necessary to set the 
'rows and columns if we provide a complete
'2D array
oGridData.Data = mydata
logmessage "Columns: " & oGridData.ColumnCount & _
	" Rows: " & oGridData.RowCount
logmessage "Data contents:"
'Print out the table of items
dim i
for i = 0 to oGridData.RowCount - 1
	logmessage oGridData.GetCell( 0, i ) & vbTab & vbTab & vbTab & _
		oGridData.GetCell( 1, i )
next 
' Output of this script is the following
' (the date on the last line will change each time it is run)
'
'INFO : "Columns: 2 Rows: 4"
'INFO : "Data contents:"
'INFO : "12000			Col1Row0"
'INFO : "Col0Row1			4.567"
'INFO : "			"
'INFO : "Col0Row3			8/27/2003 11:18:12"

2. JScript Example

//Demonstrate setting data with the GridData.Data method
var oGridData = XSIFactory.CreateGridData();
//In jscript we have no 2-D array but we
//can provide a 1-D array and tell the GridData how
//to interprete it
var myData = new Array( 8 );
//Initialize the data (we leave one row empty)
myData[ 0 ] = 12000;
myData[ 1 ] = "Col1Row0";
myData[ 2 ] = "Col0Row1";
myData[ 3 ] = 4.567;
myData[ 6 ] = "Col0Row3";
myData[ 7 ] = new Date(); 	//Store current time
oGridData.RowCount = 4 ;
oGridData.ColumnCount = 2 ;
oGridData.Data = myData ;
logmessage( "Columns: " + oGridData.ColumnCount + 
	" Rows: " + oGridData.RowCount ) ;
logmessage( "Data contents:" ) ;
//Print out the table of items
for ( var i = 0 ; i < oGridData.RowCount ; i++ )
{
	logmessage( oGridData.GetCell( 0, i ) + "\t\t\t" + 
				  oGridData.GetCell( 1, i ) ) ;
}
//Output of this script is the following
//(the date on the last line will change each time it is run)
//
//INFO : "Columns: 2 Rows: 4"
//INFO : "Data contents:"
//INFO : "12000			Col1Row0"
//INFO : "Col0Row1			4.567"
//INFO : "undefined			undefined"
//INFO : "Col0Row3			Wed Aug 27 11:25:29 EDT 2003"

See Also

GridData.SetColumnValues GridData.SetRowValues