Saving Your Commands in a Script File

So far, you have entered your commands into the Listener window. If you had to stop at some point, and couldn't finish some code in one session, you would have to start all over, entering the commands you already used in the previous session. MAXScript allows you to store your commands in an external file that you can load and run.

The general procedure for storing commands in a script file is to click the New Script button in the MAXScript rollout, and type commands in the Script Editor window that opens. Because you have already entered a lot of commands in the Listener window, you can copy them from that window into the Script Editor window.

To copy tutorial commands from the Listener into the script editor window:

  1. Click the New Script button in the MAXScript rollout on the Display panel.

The Script Editor window appears with the title "Untitled - MAXScript".

  1. Position the Script Editor window side-by-side or below the Listener window so that you can copy and paste text between the two windows.

  2. In the Listener window, select the black command line from the Drawing a Box with MAXScript topic (mybox = box length:20 width:20 height:20)

  3. Press CTRL+C on your keyboard to copy the text to the Clipboard.

  4. Click the Script Editor window to place the cursor in it, and press CTRL+V on your keyboard to paste the command into the Script Editor window.

Tip: You can also drag selected text from the Listener and drop it in the Script Editor, or vice versa.

  1. Choose File > Save in the Choose File Name for Save dialog, navigate to your \Scripts directory. Name your script file and click Save.

Your script file is saved and the script editor window title changes to " - MAXScript."

You have now saved your first script file. MAXScript uses the .ms extension for script files. It is good general practice to save all of your script files into the scripts directory.

Next Topic

Loading and Running your Script File