MAXScript Editor - Defining And Using Abbreviations

The Tabbed MAXScript Editor introduced in 3ds Max 2008 lets you define and use abbreviations of common used words to speed up the typing of scripting code.

Defining Abbreviations

The abbreviations are defined in a file called MXS_Editor_Abbrev.properties which is empty by default after a fresh installation of 3ds Max and is located in the 3ds Max root directory, but can be easily accessed and edited using the Tools >Open Abbreviations.properties Editor Menu option.

An abbreviation is defined in the form

<AbbrevName>=<Expanded Form>

The abbreviation names can contain any characters (except control chars lile \r or \n), including high ASCII characters (accented characters). Abbreviation names cannot start with #, space or tab (but can contain spaces inside the name) and cannot contain the '=' character inside. Abbreviations names are limited to 32 characters.

The expanded form may contain new line characters indicated by '\n' and a caret position indicated by the '|' character. To include a literal '|' character, use '| |'. When expanding, the names don't need to be separated from the previous text. For example, if you define 'é' as 'é', you can expand it inside a word. If a name is the ending of another one, only the shorter will ever be expanded. For example if you define 'ring' and 'gathering', the later will see only the 'ring' part expanded.

You can define abbreviation definitions for any word, special character or expression that you find yourself typing in too often or is too long to remember.

FOR EXAMPLE,

The following are some possible abbreviations for accelerating GUI creation:

   cd=CreateDialog
   nf=newRolloutFloater
   rof=rendOutputFilename

After defining the abbreviations, press Ctrl+S to save the MXS_Editor_Abbrev.properties file to disk.

Using the Expand Abbreviation Feature

Press Ctrl+Nto open a new Untitled script in a new tab.In the new script, enter

   nf

While the cursor is still at the end of the abbreviation, press Ctrl+SHIFT+A. The abbreviation will immediately turn into

   new Rollout Floater

Using the Insert Abbreviation Feature

Alternatively, position the cursor at the desired location in the editor and press Ctrl+SHIFT+R to open a small dialog listing all defined abbreviations.

Either select an entry from the list or type in an existing abbreviation and press the Insert button to add the expanded word to your code.

Using the Abbreviation Feature To Write Code Fragments

Since the expanded version can contain new line characters, it is possible to define abbreviations that contain prototype code and even full functions you need often to be inserted into your code.

FOR EXAMPLE,

You can define the following for loop prototype code as abbreviation in the file MXS_Editor_Abbrev.properties

   for do =for i = 1 to 100 where true do\n(\n)\n 

After defining the abbreviations, press Ctrl+S to save the MXS_Editor_Abbrev.properties file to disk.

If can now type in a script file

   fordo

and after pressing Ctrl+SHIFT+A, the following code would appear:

   for i=1 to 100 where true do ( ) 

Now you could customize this prototype code by modifying the from and to values, entering a valid while condition in place of true and writing some code into the body of the for loop, but it would have saved you some typing.