OnEndSelectionChange (GridData)


説明

グリッド データ パラメータに関連付けられているグリッド ウィジェットに選択の変更を適用した後に発生します。


適用対象

スクリプト言語で実装されたカスタム プロパティの GridData パラメータ。


構文

function <property_name>_<parameter_name>_OnEndSelectionChange()

{

...

}
def <property_name>_<parameter_name>_OnEndSelectionChange():

				...
Function <property_name>_<parameter_name>_OnEndSelectionChange()

				...

End Function
sub <property_name>_<parameter_name>_OnEndSelectionChange 

{ 

	... 

}

<property_name> は、PluginRegistrar.RegisterProperty の呼び出しで指定されている名前です。この名前に含まれるスペースはアンダースコアに置き換えられます。 たとえば、My Property という名前のプロパティを登録する場合、コールバック関数の名前の先頭は My_Property になります。

<parameter_name> は、CustomProperty.AddGridParameter の呼び出しで指定されている名前です。名前にスペースが含まれていればアンダースコアに置き換えられます。たとえば、My Grid という名前のグリッド パラメータを追加する場合、コールバック関数の名前の先頭は <property_name>_My_Grid になります。


パラメータ

パラメータ 言語 タイプ 説明
extra_param スクリプティング Array 1 番目の項目は選択されたセルの列と行のインデックスを含む配列です。インデックスは[col1, row1, col2, row2, ...]のように配置されます。


import win32com.client

from win32com.client import constants



def XSILoadPlugin( in_reg ):

	in_reg.Author = "Autodesk"

	in_reg.Name = "MyPropertyPlugin"

	in_reg.Major = 1

	in_reg.Minor = 0



	in_reg.RegisterProperty("MyProperty")

	#RegistrationInsertionPoint - do not remove this line



	return True



def XSIUnloadPlugin( in_reg ):

	strPluginName = in_reg.Name

	return True



def MyProperty_Define( in_ctxt ):

	oCustomProperty = in_ctxt.Source

	oCustomProperty.AddGridParameter("MyGrid")

	return True



def MyProperty_DefineLayout( in_ctxt ):

	oLayout = in_ctxt.Source

	oLayout.Clear()

	oItem = oLayout.AddItem("MyGrid")

	return True



def MyProperty_OnInit( ):

	Application.LogMessage("MyProperty_OnInit called",constants.siVerbose)

	param = PPG.MyGrid



	# Basic population of the grid data

	gridData = param.Value

	gridData.ColumnCount = 3

	gridData.RowCount = 3

	

	for col in range( gridData.ColumnCount ):

		gridData.SetColumnLabel( col, "Col %d"%col )

		gridData.SetColumnDef( col, constants.siColumnStandard )

		for row in range( gridData.RowCount ):

			if col == 0:

				gridData.SetRowLabel( row, "Row %d"%row )

			gridData.SetCell( col, row, "%d,%d"%(col, row) )



def MyProperty_OnClosed( ):

	pass



def MyProperty_MyGrid_OnEndSelectionChange( in_ExtraParams ):

	param = PPG.MyGrid

	gridData = param.Value

	

	# Retrieve the set of cells that were selected and 

	# create a string for later logging

	columnRowPairs = []

	columnRowPairs.extend( in_ExtraParams[0] )

	

	logString = "Selected cells: "

	while len( columnRowPairs ) >= 2:

		col = columnRowPairs.pop(0)

		row = columnRowPairs.pop(0)



		logString += "(%d, %d), "%(col, row)



	Application.LogMessage( logString )


関連項目