MAXScript provides a set of classes and functions and some special syntax to allow you to construct custom right-click menus that can be incorporated into the existing 3ds Max user interface. You typically use right-click menus to provide quick access to a selection of tools you have written in MAXScript. These tools would typically have no user interface, however you can create dialogs or rollout floater windows in a right-click menu to display a user interface.
A scripted right-click menu is created using the RCMenu definition construct in MAXScript, and then you register the right-click menu with 3ds Max. The top-level definition syntax is as follows:
This method will popup a menu anywhere on the screen. The controls are as follows:
Registers the specified right-click menu
Unregisters the specified right-click menu
Unregisters all right-click menus
The following script adds two items to the right-click menu: Cast Shadows and Receive Shadows. These items will be enabled only if one object is selected. If enabled, the items will be checked or unchecked based on the current state of the selected object. Choosing a menu item will flip the state of the corresponding object property.
menuItem mi_cs "Cast Shadows" checked:false
menuItem mi_rs "Receive Shadows" checked:false
on MyRCmenu open do
local sel = (selection.count == 1)
-- Enable if only one object is selected
mi_cs.enabled = mi_rs.enabled = sel
-- Set check state of items
if sel do
mi_cs.checked = $.castShadows
mi_rs.checked = $.receiveShadows
-- set up event handlers for items
on mi_cs picked do $.castShadows = (not $.castShadows)
on mi_rs picked do $.receiveShadows = (not $.receiveShadows)
-- register the rcmenu
You can register as many scripted right-click menus as you like. Each scripted right-click menu registered is appended to the right-click menu window. If a scripted right-click menu with the same name is registered twice, the old one is over written by the new one.
If a runtime error occurs while executing a scripted right-click menu, an error message is displayed in Listener. The right-click menu will not be disabled.