Getting the selected ICE nodes

The context for custom menu callbacks gives you access to the current view instance, so you can use the selection view attribute to get the selected ICE nodes. See line 35 in the example.

import win32com.client
from win32com.client import constants

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
	in_reg.Author = "blairs"
	in_reg.Name = "My_ICETreeUserTool_Plugin"
	in_reg.Major = 1
	in_reg.Minor = 0

	#RegistrationInsertionPoint - do not remove this line

	return true

def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
	return true

def My_ICETreeUserTool_Menu_Init( in_ctxt ):
	oMenu = in_ctxt.Source
	oMenu.AddCallbackItem("My ICE Tree User Tool","OnMyICETreeUserTool")
	return true

def OnMyICETreeUserTool( in_ctxt ):
	itv = in_ctxt.GetAttribute("Target")
	LogMessage( 'View: ' + itv.Name )
	# get the selected nodes
	nodes = itv.GetAttributeValue('selection')
	LogMessage( 'Selected nodes: ' + nodes )

Leave a Reply

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

You are commenting using your 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