赞
踩
//
MAXScript Interface
MAXScript is the 3ds Max built-in scripting language. Its main interface, the MAXScript menu, contains various commands for creating and working with scripts. In addition, the status bar contains a MAXScript Mini Listener, and MAXScript functionality is also available from the Utilities panel.
For detailed information about MAXScript, open the MAXScript Help, available from Help menu MAXScript Help.
Topics in this section
New Script opens a new MAXScript Editor window. Use this window for writing a new script.
For detailed information about the MAXScript utility, open the MAXScript Help, available from Help menu MAXScript Help.
Open Script opens a standard file dialog for choosing an existing script. A new MAXScript Editor window then displays the selected script.
For detailed information about the MAXScript utility, open the MAXScript Help, available from Help menu MAXScript Help.
These files are saved as text files, and you can open them using the Open Script command.
MS
MAXScript file (.ms).
MCR
MacroScript file (.mcr). MacroScripts define action items managed by the Customize User Interface dialog.
Run Script opens a common file open dialog for choosing an existing script. MAXScript then reads and executes the selected script. Any output is printed to the Listener window.
For detailed information about the MAXScript utility, open the MAXScript Help, available from Help menu MAXScript Help.
You can’t open these file types for editing in 3ds Max, but you can run them, and you can access them by using third party software.
MSE
MAXScript Encrypted file (. mse). An encrypted MAXScript uses a binary format that can’t be read or edited, but that 3ds Max can run as it would an ordinary MS file.
MZP
MAXScript Zip Package file (. mzp). A MAXScript Zip package collects the related files that make up a scripted tool into a single file that you can run as you do an ordinary MS file. A MAXScript Zip Package can contain script source, bitmaps, icons, and so on.
The MAXScript Listener window is primarily an interactive interpreter for the MAXScript language. It is similar to a DOS command-prompt window.
When you enter a MAXScript command in the lower (white) pane of this window, the command is executed immediately.
The Listener window is appropriate for performing interactive work and developing small code fragments. Each command you execute in the Listener is actually an expression with a result that the Listener prints out after each execution. You can enter any MAXScript expression or sub-expression in the Listener for evaluation, and the Listener prints out its result.
The Listener is divided into two panes. The top (pink) pane is the Macro Recorder pane, and the bottom (white) pane is the output pane. When the Macro Recorder is enabled, everything it records, such as actions you perform in a viewport, is displayed in the Macro Recorder pane. The results from scripts are displayed in the output pane. The output of code executed in the Macro Recorder pane is always directed to the output pane so as not to clutter the recordings. Both panes allow you to cut-and-paste, drag-and-drop, edit, select, and execute code. You can resize the panes by dragging the split bar between them.
The left-end of the status bar contains a resizable Mini Listener. If the Mini Listener is not visible, drag the vertical split bar at the left end of the status bar rightward to reveal the Mini Listener. The Mini Listener panes act as single-line windows for the current line in the corresponding Listener panes. The Mini Listener panes always show what you are typing or where the edit cursor is placed in the Listener panes. Conversely, anything you type into a Mini Listener pane is entered into the corresponding Listener pane at the current edit cursor position.
You can display the Listener in a viewport by clicking or right-clicking the POV viewport label, then choose Extended Viewports MAXScript Listener from the menu.
When you open the MAXScript Listener in this way, and then change the viewport POV, 3ds Max opens the Listener in a window of its own.
For detailed information about the MAXScript utility, open the MAXScript Help, available from Help menu MAXScript Help.
The MAXScript Macro Recorder captures many of the actions performed by the user, and generates the MAXScript commands that correspond to those actions.
Output from Macro Recorder is displayed in the Macro Recorder pane of the MAXScript Listener window. Several filtering options are available that control what types of user actions are recorded, whether the generated MAXScript commands contain explicit object references or are selection-relative, and whether the generated MAXScript commands contain absolute or relative transforms and coordinates. These options are set using the MacroRecorder menu in the Listener window. The default option settings are specified in the MAXScript page of the 3ds Max Preferences dialog, as described in MAXScript Preferences. You can also make and change these settings by editing the [MAXScript] section of the 3dsmax.ini file.
While many areas in 3ds Max generate Macro Recorder output, there are also many areas that do not. In general, most controls on the 3ds Max menu bar, toolbars, status bar, Create panel, and Modify panel generate Macro Recorder output. If the button invokes a secondary dialog, changing settings or performing actions in the secondary dialog typically do not generate Macro Recorder output. In the Create and Modify panels, Macro Recorder output is typically generated if the object or modifier can be created by MAXScript. In rare cases, the plug-ins implementing an object or modifier have not been updated to support Macro Recorder, so that object or modifier does not generate Macro Recorder output.
MAXScript supports text drag-and-drop onto toolbars to create Macro Script buttons. You can select and drag text from any text window, such as the Listener window panes or Editor window, onto any visible toolbar. The cursor changes to an arrow with a + sign when it is permissible to drop the text. Dropping it at that point adds a Macro Script button to the toolbar with the dropped text as the body of the Macro Script. A typical usage of this would be to drag text from the Macro Recorder pane onto a toolbar to make a button that does the sequence of events just recorded.
For detailed information about the MAXScript utility, consult the MAXScript Help, available from Help menu MAXScript Help.
Visual MAXScript is a powerful interface to the 3ds Max scripting language, making the MAXScript feature easier to learn and use. With Visual MAXScript, you can quickly create UI elements and layouts for scripting.
For detailed information about Visual MAXScript, open the MAXScript Help, available from Help menu MAXScript Help.
The MAXScript debugger implements the first half of a script development and debugging environment.
The debugger dialog allows the main thread of 3ds Max to be suspended, the values of global and local variables to be examined and altered while the thread is not running, MAXScript commands to be executed from a command line, and the execution to be suspended using method calls from inside the MAXScript code. The debugger also lets you stop or continue the execution of the suspended code.
For detailed information about the MAXScript debugger, consult the MAXScript Help, available from Help menu MAXScript Help.
3ds Max allows you to enter scripting commands directly on the command line. When you launch 3ds Max from a DOS command line, you can have it run a specified launch MAXScript or Python script. This can be useful for tasks such as unattended batch rendering.
This capability uses the existing -U command line switch that names a utility to be run when 3ds Max is started. The -U switch allows an optional extra argument which, for MAXScript and Python, is taken to be the name of the launch script to run. The case (capitalization) of MAXScript must be as shown in the following example (entered after you CD to 3ds Max directory):
3dsmax -U MAXScript rendercams.ms
This example command line would launch the 3ds Max executable , start MAXScript, and then have it run the launch script rendercams.ms.
The following example launch script loads two scenes, renders frames from each of the cameras in them, and then quits 3ds Max:
loadMaxFile "foo.max"
for c in cameras do render camera:c outputfile:("foo_"+c.name+".bmp")
loadMaxFile "baz.max"
for c in cameras do render camera:c outputfile:("baz_"+c.name+".bmp")
quitMax #noPrompt
This example makes use of the quitMax() method to exit 3ds Max when the script is finished. Launch scripts need not be batch scripts as in this example, but may be used to condition 3ds Max for interactive use, for example by loading a scene file and setting some user-interface options.
The normal startup scripts, startup.ms and those in the \scripts\startup directory, are run before the launch script. It is also possible to install scripts into individual scene files that run automatically when that scene is open or closed or at certain other events.
Note: Command line -U MAXScript startup scripts are run after 3ds Max has completely booted and the standard scripts and startup scripts have been run.
The following switches work specifically with MAXScript and Python files and functions.
Switch | Effect |
-mi | Starts 3ds Max in a minimized mode – but never allows you to open the window for interactive usage. |
-mxs | This switch is essentially the same as -U MAXScript file.ms, but avoids the need for the .ms file. You can follow the switch with MAXScript commands. |
-silent | Comparable to the MAXScript command, setSilentMode, this switch suppresses all MAXScript and 3ds Max UI dialogs so that batch scripts specified by the –U command do not get interrupted. |
-u MAXScript <filename> | Opens a specified MAXScript file. |
-u PythonHost <filename> | Opens a specified Python script file. |
Examples of desired syntax usage:
3dsmax.exe -silent -mxs "for c in cameras do render c outputFile:(c.name + \".bmp\") vfb:off " file.max
This example starts 3ds Max in silent mode, opens file.max and renders each camera view to a BMP file without showing the Rendered Frame Window. Note that quoted strings inside the passed script need to be escaped.
3dsmax.exe -q -mi -U MAXScript \\server1\folder\myScript.ms \\server2\folder\file.max
This example suppresses the splash screen while starting 3ds Max in a minimized state, opens file.max from a network server and runs myScript.ms found on another server. If myScript.ms contains the same commands as the first example, both of these examples would give the same results.
3dsmax.exe -q -silent -mip -mxs "for c in cameras do render c outputFile:(c.name + \".bmp\") vfb:on; quitMAX() #nopromptfile.max" file.max
The final example suppresses the splash screen while starting 3ds Max in silent mode and in a permanently minimized state, opens file.max, renders each camera view to a BMP file showing the Rendered Frame Window, then exits 3ds Max.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。