The MAXScript Editor Windows

MAXScript Editor windows are text editor windows you can open within 3ds Max and use to create or edit text files, notably MAXScript script files. Press Open Script on the MAXScript rollout, File > Open Script in the Listener menu bar, or MAXScript > Open Script in the 3ds Max menu bar to open an existing script file. MAXScript opens the selected script in a modeless MAXScript Editor window, such as the one shown.

editor_intro.gif

To create a fresh script, press New Script on the MAXScript rollout, File > New Script in the Listener menu bar, or MAXScript > New Script in the 3ds Max menu bar to open a new, empty MAXScript Editor window. You can write and edit text, including drag-and-drop editing, in the MAXScript Editor as you would in other editors like WordPad. The menus are similar to those in many standard Windows text editors. You may have any number of MAXScript Editor windows open at the same time.

MAXScript Editor is suited to developing longer scripts or code fragments you want to keep. You can edit and test parts of them until they are complete, then save your code in a script file for later use. This is a common method for developing large scripts, utilities, and function libraries.

You can select one or more text lines and drag them to a 3ds Max toolbar to create a Macro Script containing the selected lines. For more information, see Defining Macro Scripts.

You can open a MAXScript Editor window from within the Listener or from other running scripts by calling the edit() method. The syntax for the edit() method is:

edit <filename_string>

where <filename_string> is a string literal or an expression that evaluates to a string, and specifies the name of the file whose contents are to be loaded into the new MAXScript Editor window.

Example uses are:

edit "my_script.ms"

or

scriptfile="my_script.ms"

edit scriptfile

The file will be searched for in the following directories, in the order listed:

You can create an empty MAXScript Editor window from within the Listener or from other running scripts by calling the newScript() method. The syntax for the newScript() method is:

newScript()

Opens an empty MAXScript Editor window and returns a WindowStream value that may be used as the target for print and format operations. This is useful for directing output to a separate window for ease of inspection or editing, or later saving to a file. Output to a WindowStream is inserted at the current cursor position in that window.

For example:

debug = newScript()

...

print $foo to:debug

...

format "name is %\n" obj.name to:debug

If you need to locate the source of a scripted function, you can use the showSource() method. It displays a MAXScript Editor window containing the source file in which the function was defined, positioned at the function's definition.

The form is:

showSource <fn>

 

 

editorShowPath

new.gif NEW in 3ds Max 9: The new system global variable editorShowPath controls whether the MAXScript Editor will display the full path of the edited script (true, default in 3ds Max 9), or only the file name (false, the only mode prior to 3ds Max 9) in the title bar. Changing the value will update the open MAXScript editor windows.

new.gif NEW in 3ds Max 9: When doing an Open or Save As from an editor window, and there is a filename associated with the editor window, the file open/save dialog will open to the filename's path. When doing an Open, Save, or Save As from an editor window without a filename, or from Listener or the main max window, the last directory specified in a MAXScript script file open/save dialog will be used (unless the user cancelled out of the dialog).

A MAXScript Editor window has the following features:

For commands use within the MAXScript Editor window, see MAXScript Editor Commands.