Using Python for RV_Init callbacks of relational views


Want to use Python to implement an RV_Init callback in an .xsivw file? Here’s how:

<script language="Python"><![CDATA[
def RV_Init( in_rv ):
	Application.LogMessage( "RV_Init" )
	
	# COM programming ( in_rv is pointer to IUnknown ) 
	import pythoncom
	oRV = in_rv.QueryInterface( pythoncom.IID_IDispatch )
	
	import win32com.client.dynamic
	oRV = win32com.client.dynamic.Dispatch( oRV )
	
	Application.LogMessage( Application.Classname(oRV) )
	
	for i in range(0,oRV.Views.Count):
		oView = oRV.Views(i)
		Application.LogMessage( oView.Name + " " + oView.type 	)

]]></script>