MacroScripts for New Users

MacroScripts were first introduced in 3ds Max 3. They were originally implemented to accommodate the output of the Macro Recorder (thus the name) and were intended for use as buttons on the toolbars.

A MacroScript is generated automatically when scripting code (from the MacroRecorder output, from the MAXScript Listener or from a MAXScript editor) is dragged and dropped onto a toolbar. The new scripts have the extension .mcr and are written by default to the UI\UserMacros folder. (In versions prior to 3ds Max 9 the .mcr files were written next to the shipping MacroScripts in the UI\MacroScripts folder under the application root, but the introduction of the Microsoft Vista OS restricted the access to that folder and the new \UserMacros folder has to be introduced).

The location of the UserMacros folder is configured via Main Menu > Customize > Configure System Paths > Additional Macros. It can be revealed by typing in the MAXScript Listener

getDir #userMacros

To create a MacroScript using Drag And Drop:

  1. Select some code in the MacroRecorder output, the MAXScript Listener or in a MAXScript editor.
  2. Click and Drag the selection to a toolbar while holding the left mouse button pressed.
  3. Drop the selection on the toolbar by releasing the left mouse button.

    Result:A new button will be created, showing a generic MacroScript icon. The new script will be named "MacroN" where N is a unique number incremented after each drag and drop operation. The category of the new script will be "DragAndDrop".

Later in 3ds Max 4, the UI was extended to allow the usage of MacroScripts as ActionItems in Menus, QuadMenus, Toolbars and Keyboard Shortcuts. Currently, this is probably the most common form of scripts found in 3ds Max and is vital to UI customizability.

Of course, a script developer can write the same form of scripts manually or use automatically generated MacroRecorder code as template for manual enhancements. The developer’s source code might also be contained in an .ms file.

A typical MacroScript will usually start like this:

macroScript scriptName category:"CategoryName"
(
...
)

Note the category: name. You will need this name in order to be able to quickly locate the script in the Customize dialog.

To install a MacroScript:

  1. Click the MAXScript item in the Main Menu, select Open Script...

    Alternatively, go to the Utilities panel, open the MAXScript Utility, press Open Script...

  2. Locate and select the script and press Open.
  3. Note the name of the MacroScript and the Category name.
  4. In the MAXScript Editor, click Tools menu and select Evaluate All or press Ctrl+E. This will evaluate the script.
  5. Go to Customize > Customize User Interface and select the desired Tab (Keyboard, Toolbars, Quads or Menus)
  6. Locate the Category you noted in 3.
  7. Search in the Category for the name you noted in 3.
  8. Drag the script to the toolbar, Menu or QuadMenu or assign to a Shortcut.

An evaluated MacroScript appears in the Customize... dialog’s categories list of Action Items. The evaluated version of the script remembers its source’s location. As soon as a MacroScript definition is evaluated, a copy of the source is automatically saved in the User Macros folder with a new name comprised of the Category Name, the MacroScript’s name and the .mcr extension.

If you change or update the script by evaluating a newer / different version with the same name and category, the copy of the script in the UI\UserMacros folder will be overwritten with the actualized version.

All scripts in UI\MacroScripts which contains the factory-defined MacroScripts and UI\UserMacros containing the user-defined ones will be automatically evaluated on startup and will be available to the user in future sessions. To remove a MacroScript permanently, you should remove the respective .mcr file from the UI\UserMacros folder.

It is not advisable to have any MacroScript sources in autos tart folders like the \Scripts\Startup or the plug-in paths as this would mean a double evaluation of the same source code from two different locations. Store sources of MacroScripts (your own creations, free downloads from the web or commercial scripts) at paths that are not listed in your Configure Paths dialog. This way only the automatically managed content of the UI\MacroScripts and UI\UserMacros folders will be used by 3ds Max.

Topics:

MAXScript for New and Casual Users

Scripted Utilities for New Users

Scripted Plug-ins for New Users

Scripted Functions for New Users

MAXScript DLX Extensions for New Users

See Also