Notifications
Clear all

[Closed] How to run macros in a script

Hi, I am trying to adapt the CommonTools to my fulfill my need, I would like create certain buttons to control the MaxScript. I tryed to find the way to call the macroscript used in max to openScript, runScript, Macro Recorder, etc… however i could find a way to access this kind of macro. So please I will be very grateful if anyone could tell me how i can access from a script to the macro of max.

Regards
ting

5 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Check out the macros structure (documented on the page titled “Macro Scripts”) in the Reference.

For example
macros.run <category_string> <name_string>

Pass the name of the category and of the macro itself and it will be run.

Thank Bobo, however I already checked the macros.* before to post my question and i couldnt get it to work. I dont know what are the <category_string> and the <name_string> for the follogin macros: New Script, Open Script, Run Script and Macro Recorder Toggle. If anyone could help me out with this i will be very gratefull.

Thank again Bobo to make my process of learning MaxScript easier.

Regards,
ting

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Not all Menu Items are actully MacroScripts. The ActionItems system of Max can be populated by both plugins and scripts, so many of the icons and menu items you see are not scritped but exposed by the system.

You can see whether a menu item is a MacroScript or not by opening the Customize dialog in Menu tab and right-clicking on the menu items in the right tree structure – if the option “Edit Macro Script” is disabled, it is not a MacroScript…

But you can use the MacroRecorder to see what the actionMan action numbers for these operations are (except for the MacroRecorder action itself, which of course cannot be recorded, but happens to be just one above Run Script…)

actionMan.executeAction 0 “40468” – MAX Script: Open Script
actionMan.executeAction 0 “40469” – MAX Script: New Script
actionMan.executeAction 0 “40470” – MAX Script: Run Script
actionMan.executeAction 0 “40471” – MAX Script: Toggle MacroRecorder

Hi Bobo, I am tring to do in that way:

on newScript_btn pressed do
(
macros.run “MAX Script” “New Script”
)

however i get this error:

“–Runtime error: No shuch macro-script: New Script”

What is wrong ?

Thank in advance,
ting

THANK VERY MUCH Bobo, it works perfect. I tried before using the method that you suggested to me however i didnt write the complete command so that is why it dosnt work perfectly.

Thank Bobo_ting_