Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

MXS: MenuMan ? (Max2020)

MXS: MenuMan ? (Max2020)

istan
Advisor Advisor
894 Views
6 Replies
Message 1 of 7

MXS: MenuMan ? (Max2020)

istan
Advisor
Advisor

Is this example supposed to work?

 

-- This example adds a new command to MAX's default right-click quad menu
if menuMan.registerMenuContext 0x36690115 then
(
-- Get the default viewport right-click quad menu
local quadMenu = menuMan.getViewportRightClickMenu #nonePressed
-- Get the lower-left menu from the quad
local menu = quadMenu.getMenu 3
-- create a menu item that calls the sample macroScript
local testItem = menuMan.createActionItem "MyTest" "Menu Test"
-- Add the item to the menumenu.addItem testItem -1
)

 https://help.autodesk.com/cloudhelp/2017/ENU/MAXScript-Help/files/GUID-258F6015-6B45-4A87-A7F5-BB091... 

 

0 Likes
Accepted solutions (1)
895 Views
6 Replies
Replies (6)
Message 2 of 7

larryminton
Autodesk
Autodesk
Accepted solution
From the mxs help file:
menuMan.createActionItem "macroScriptName" "macroScriptCategory"
This method creates a new menu item that can be added to a menu. The item is an action that executes the macro script with the given name and category. This returns "undefined" if there is no macroScript with the given name and category.
 
If I don't evaluate the 'macroScript MyTest' script shown in the help file immediately above this example script, then running:
-- create a menu item that calls the sample macroScript
testItem = menuMan.createActionItem "MyTest" "Menu Test"
returns 'undefined', and then calling:
subMenu.addItem testItem -1
gives a runtime error. 
 
I would expect that is the runtime error you are seeing.  If you first evaluate the macroscript definition, you should be good.
 
In a non-example script, the value of 'testItem' should be checked before trying to use it.
 

Larry Minton
Principal Engineer, M&E-Design Animation
0 Likes
Message 3 of 7

istan
Advisor
Advisor

Got it thx!

0 Likes
Message 4 of 7

istan
Advisor
Advisor

Now it would be helpful, to get exactly this example in C++ !

0 Likes
Message 5 of 7

pi3c3
Participant
Participant

Hi%

 

I have actually figure out how you can add a QuadMenu to your menu prior max2025.

Also you have to be careful with the .mnux files here:

C:\Users\%username%\AppData\Local\Autodesk\3dsMax\2024 - 64bit\ENU\en-US\UI
C:\Users\%username%\AppData\Local\Autodesk\3dsMax\2024 - 64bit\ENU\en-US\UI\Workspaces\usersave

Clean up the entries with -1 that matches your plug-in. This crashes max when you want to edit the menu within the QuadMenu editor.

 

To make it work, the best way to init it

 

<MenuContext type="1" typeName="kMenuContextQuadMenu" contextID="314757" title="My Plugin Context">
    <Context menuID="-1" title="MyPlugin Quad" showAll="0" />
    <RightClickContexts>
        <Context menuID="-1" contextID="0" />
    </RightClickContexts>
</MenuContext>

 

The actual code that registers your menu. The best way to register it is somewhere in the init process. It can be the __declspec( dllexport ) int LibInitialize(void) in the DllEntry, or in your : public .GUP Start() method or in an FPInterfaceDesc etc... 

void CreateQuadMenu()
{
	IMenuManager* menuman = GetCOREInterface()->GetMenuManager();

	// Regsitering a Context to menuman
	MenuContextId ContextID = 01234567; // Set an ID... Whatever you want
	menuman->RegisterQuadMenuContext(ContextID, L"My Quad Menu Context");
	IMenuContext* Context = menuman->GetContext(ContextID);
	IQuadMenuContext* QuadMenuContext = dynamic_cast<IQuadMenuContext*>(Context);

	if (QuadMenuContext)
	{
		// Create an IQuadMenu
		IQuadMenu* QuadMenu = GetIQuadMenu();
		QuadMenuContext->SetRightClickMenu(IQuadMenuContext::RightClickContext::kNonePressed, QuadMenu);

		// Creating Quad Menu quadrants
		IMenu* quadrant1 = GetIMenu();
		IMenu* quadrant2 = GetIMenu();
		IMenu* quadrant3 = GetIMenu();
		IMenu* quadrant4 = GetIMenu();
		quadrant1->SetTitle(L"Quadrant 1");
		quadrant2->SetTitle(L"Quadrant 2");
		quadrant3->SetTitle(L"Quadrant 3");
		quadrant4->SetTitle(L"Quadrant 4");

		// Add the quadrants to your QuadMenu
		QuadMenu->AddMenu(quadrant1);
		QuadMenu->AddMenu(quadrant2);
		QuadMenu->AddMenu(quadrant3);
		QuadMenu->AddMenu(quadrant4);

		// Creating the entries for your quadrants
		IMenuItem* item1 = GetIMenuItem();
		IMenuItem* item2 = GetIMenuItem();
		IMenuItem* item3 = GetIMenuItem();
		IMenuItem* item4 = GetIMenuItem();
		item1->SetActionItem(YourActionItemPtr1);
		item2->SetActionItem(YourActionItemPtr2);
		item3->SetActionItem(YourActionItemPtr3);
		item4->SetActionItem(YourActionItemPtr4);

		// Adding the entries to your quadrants
		quadrant1->AddItem(item1);
		quadrant2->AddItem(item2);
		quadrant3->AddItem(item3);
		quadrant4->AddItem(item4);

		// Adding the menu to your context
		QuadMenuContext->SetMenu(0, QuadMenu, L"My Quad");
	}
}

 

0 Likes
Message 6 of 7

istan
Advisor
Advisor

Wow this was fast 😉 Thanks for the code anyway.

In the meantime I'm on Max2026 and not using Quadmenus anymore - I switched everything to C++/QT..

 

0 Likes
Message 7 of 7

pi3c3
Participant
Participant

Yeah well I just wanted to share it because of backward compatibility. 🙂 It's better to have it here than just keeping it for myself. 🙂

0 Likes