MacroScripts for New Users

A MacroScript is generated automatically when scripting code (from the MacroRecorder output, from the Scripting Listener or from a Scripting Editor) is dragged and dropped onto a toolbar. The new scripts have the extension .mcr and are written by default to the #userMacros folder (see 3ds Max System Directories).

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 Scripting Listener

   getDir #userMacros

To create a MacroScript using Drag And Drop:

  1. Select some code in the MacroRecorder output, the Scripting Listener or in a Scripting 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".

You can also use MacroScripts as ActionItems in Menus, QuadMenus, Toolbars and Keyboard Shortcuts.

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 Scripting 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 #userMacros 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 #userMacros folder will be overwritten with the actualized version.

All scripts in #macroScripts which contains the factory-defined MacroScripts and #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 #userMacros folder.

It is not advisable to have any MacroScript sources in auto start folders like the #startupScripts 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 #macroScripts and #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