Adding a named section to a menu


Here’s a Python snippet that shows how to add a section to a menu like the ICE > Particles > Create menu:

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 = "NewCommandPlugin"
	in_reg.Major = 1
	in_reg.Minor = 0

	in_reg.RegisterCommand("NewCommand","NewCommand")
	in_reg.RegisterMenu(constants.siMenuTbICEParticlesCreateID,"ICEParticlesCreateCustom_Menu",false,true)
	
	#RegistrationInsertionPoint - do not remove this line

	return true

def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	return true

def ICEParticlesCreateCustom_Menu_Init( in_ctxt ):
	oMenu = in_ctxt.Source
	
	# Add section divider
	oItem = oMenu.AddItem( "Custom", constants.siMenuItemSection )
	oItem.SetBackgroundColor(178,191,194)
	
	# Add custom menu items
	oMenu.AddCommandItem("My ICE Deformer","NewCommand")
	oMenu.AddCommandItem("Another ICE Deformer","NewCommand1")
	return true