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>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s