GridData.Data operator

導入

v4.0

詳細

セルデータの 2D 配列全体を設定したり、戻したりします。データはVariantの 2D の SAFEARRAY で表されます。

第 1 次元が列、第 2 次元が行です。

事前にGridData.ColumnCountArrayを設定しておくと、1D の SAFEARRAY またはJscriptGridData.RowCountを使用してプロパティを設定することもできます。この場合は、配列内にRow * Column項目を含め、1列ごとではなく1行ごとにデータを解釈させる必要があります。

このプロパティを使用すると、2D 配列を戻す任意の Softimage メソッドからデータを操作できます(ClusterPropertyデータなど)。以下にその一例を挙げます。

1. VBScript の例

'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 の例

//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"

関連項目

GridData.SetColumnValues GridData.SetRowValues