How do I add a custom submit script to the menu, like the photo below?
macroScript RenderFarm724
category:"Render724"
tooltip:"Render724 Submit"
buttontext:"Submit Max to Render724 Farm"
--Icon:#("3ds Max Facebook - Help_Web_Facebook_Help - 32",32)
(
fileIn (getDir #userScripts+ "\\Rende724.ms")
)
(
local theMainMenu = menuMan.getMainMenuBar()
local theRender724Menu = menuMan.findMenu "Render724"
if theRender724Menu != undefined do
(
menuMan.unRegisterMenu theRender724Menu
menuMan.updateMenuBar()
)
theRender724Menu = menuMan.createMenu "Render724"
local theMenuDefinitionArray = #(
#(#menuitem,"SubmitMaxToRender724","Render724","Submit Max to Render724"),
#(#separator)
)
for aDef in theMenuDefinitionArray do
(
case aDef[1] of
(
default:
(
try
(
theAction = menuMan.createActionItem aDef[2] aDef[3]
theAction.setTitle aDef[4]
theAction.setUseCustomTitle true
theRender724Menu.addItem theAction -1
)catch()
)
#separator:
(
try
(
theAction = menuMan.createSeparatorItem()
theRender724Menu.addItem theAction -1
)catch()
)
)--end case
)--end aDef loop
theSubMenu = menuMan.createSubMenuItem "Render724" theRender724Menu
theMainMenu.addItem theSubMenu -1
menuMan.updateMenuBar()
)--end script
Menu comes but none of them have submenu and no function
local theMenuDefinitionArray = #(
#(#menuitem,"RenderFarm724","Render724","Submit Max to Render724"),
#(#separator)
)
In your code, you had the wrong name for the MacroScript. You are supposed to add the name of the MacroScript as second element of the array, and the Category as 3rd. For some reason, you had
“SubmitMaxToRender724” as the MacroScript name, so the call to menuMan.createActionItem() returned undefined, and the call to setTitle() caused the error
-- Unknown property: "setTitle" in undefined
which was caught by the try()catch() silently and produced no menu item.
Woow Thank you very much indeed! @Bobo And ThinkBox Family
I execute it successfully, but I put it in the usermacros folder. But he’s not working right now. Did we put it in a place other than usermacros directory?
That’s where we put ours. Maybe work backward from the manual install docs for SMTD.
unfortunately does not work in macroscripts folder. I used to run it once. The macroscript works successfully in the maxscript editor.
macroScript RenderFarm724
category:"Render724"
tooltip:"Render724 Submit"
buttontext:"Submit Max to Render724 Farm"
--Icon:#("3ds Max Facebook - Help_Web_Facebook_Help - 32",32)
(
fileIn (getDir #userScripts+ "\\render724.ms")
)
local theMainMenu = menuMan.getMainMenuBar()
local theRender724Menu = menuMan.findMenu "Render724"
if theRender724Menu != undefined do
(
menuMan.unRegisterMenu theRender724Menu
menuMan.updateMenuBar()
)
theRender724Menu = menuMan.createMenu "Render724"
local theMenuDefinitionArray = #(
#(#menuitem,"RenderFarm724","Render724","Submit Max to Render724"),
#(#separator)
)
for aDef in theMenuDefinitionArray do
(
case aDef[1] of
(
default:
(
try
(
theAction = menuMan.createActionItem aDef[2] aDef[3]
theAction.setTitle aDef[4]
theAction.setUseCustomTitle true
theRender724Menu.addItem theAction -1
)catch()
)
#separator:
(
try
(
theAction = menuMan.createSeparatorItem()
theRender724Menu.addItem theAction -1
)catch()
)
)--end case
)--end aDef loop
theSubMenu = menuMan.createSubMenuItem "Render724" theRender724Menu
theMainMenu.addItem theSubMenu -1
menuMan.updateMenuBar()
--end script
MacroScripts (e.g. the result of evaluating your code above to make
macroScript RenderFarm724
category:"Render724"
tooltip:"Render724 Submit"
automatically save a copy of the macro in the usermacros folder. However, the rest of the code in your example after the macro definition, the stuff creating the menu itself, cannot be in the usermacros folder. You should put your menu creation script in the Startup scripts folder, or in a plugin folder, or a sub-folder thereof.
In the case of Deadline itself, the Setup copies the file SMTDSetup.ms which resolves the location of the Repository and loads the Menu Creator script here:
“C:\Program Files\Autodesk\3ds Max 2018\scripts\Startup\SMTDSetup.ms”
When 3ds Max starts, it evaluates the startup scripts and in this case updates the Main Menu with a Deadline item.