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_OnBeginValueChange( in_ExtraParams ):
param = PPG.MyGrid
gridData = param.Value
# Retrieve the set of cells that are about to get modified
columnRowPairs = []
columnRowPairs.extend( in_ExtraParams[0] )
returnArray = []
while len( columnRowPairs ) >= 2:
col = columnRowPairs.pop(0)
row = columnRowPairs.pop(0)
# For the sake of the example, we demonstrate returning a single accept flag
# and a per-cell flag
if col == 2:
# As soon as the modification affects the last column, we reject the
# whole value change
return False
if row == 1:
# Do not allow modification of row 1
returnArray.append( False )
else:
returnArray.append( True )
return returnArray |