Титульная страница
ISO 9000 ISO 14000
GMP Consulting
 
Mastering 3D Studio MAX R3

Previous Table of Contents Next


Viewport Type

MAXScript allows us to control the 3D viewports. You are able to set any type of viewport, but once you change to a 2D viewport (Track View, Schematic View, Asset Manager, and MAXScript Listener), you will not be able to change it again.

To get and set viewport types, you can use VIEWPORT.GETTYPE and VIEWPORT .SETTYPE, respectively. The supported viewport types are shown in Table 17.3.

Table 17.3 VIEWPORT TYPES
Name Viewport
#view_top Top view
#view_bottom Bottom view
#view_right Right view
#view_left Left view
#view_front Front view
#view_back Back view
#view_persp_user Perspective view
#view_iso_user User view
#view_camera Camera view
#view_spot Spot view
#view_shape Shape view
#view_grid Grid view
#view_track Track view

When setting Camera or Spot, if there is no camera or spot selected, the Select Camera or Spot dialog window will be shown.

You can set the active viewport using VIEWPORT.ACTIVEVIEWPORT. It will require an index number that will identify the viewport. You can use VIEWPORT .NUMVIEWS to inquire how many viewports you have.


WARNING Remember that Track View, Schematic View, Asset Manager, and MAXScript Listener will not be considered in any of these commands. Once you change a viewport to any of them, you cannot change it back using MAXScript.

Camera Views

You can manipulate Camera views, to define which camera will be used and also to find out which camera is being used in a viewport. GETACTIVECAMERA or VIEWPORT.GETCAMERA() will list the camera that is used by the current camera view.

VIEWPORT.SETCAMERA will allow us to set a camera in the current camera view. For instance, viewport.setcamera $Camera02 will set the current camera view as Camera02. If the current view is not a camera, it will return undefined.

Miscellaneous Viewport Manipulation

You can also set various viewport characteristics through MAXScript, such as redraw, safe frames, and wait cursors.

Redrawing

Some actions require us to force a redraw on screen. There are three ways to do so: REDRAWVIEWS(), COMPLETEREDRAW(), and MAX VIEWS REDRAW.

REDRAWVIEWS() will redraw only what has been changed on screen, providing a fast, but not so accurate, redraw. COMPLETEREDRAW() and MAX VIEWS REDRAW will redraw the entire screen, regardless of what was or was not changed, which will be slower but more accurate.

Safe Frames

You can turn the safe frames on or off. To do so you can use two commands, DISPLAYSAFEFRAMES or MAX SAFEFRAME TOGGLE. The latter will toggle the status of the safe frames (if they were off, they will be turned on, and vice versa). The viewports with safe frames are automatically redrawn.

To use DISPLAYSAFEFRAMES, you need to say whether it is true or false; for instance, displaysafeframes = true will turn it on for the active viewport. The viewport is not redrawn automatically, so you will need to use COMPLETEREDRAW() or MAX VIEWS REDRAW to refresh the viewport and display the safe frames.

Cursors

When the script is processing, sometimes you might want to let the user know MAX didn’t freeze. A way to do so is to change the cursor to the system wait cursor (usually an hourglass) until the process is over, and then switch it back to normal. To do so you can use SETWAITCURSOR() and SETARROWCURSOR(). They will set the cursor to the wait cursor and back to the normal arrow, respectively.

Accessing Global Functions and Properties

MAX has several configuration properties and commands that control the interface, turn buttons on or off, change Preferences options, and access scene properties. We’ll now see some of these functions and properties.

MAX Interface

There are several commands that can control MAX Global Properties or that can control the way MAX behaves. Some of them allow us to activate certain items; some turn on buttons; some change the UI configuration, etc. Let’s examine some of these helpful commands.

Controlling the Command Panel

You can use SETCOMMANDPANELTASKMODE to control which of the tabs is opened in the Command Panel. Similarly, you can use GETCOMMANDPANELTASKMODE to know which panel is activated. This is useful because some options—sub-object level, for instance—will not run if a specified Command Panel tab isn’t activated. (See Chapter 14 for details on how to turn on sub-object mode with script.)

To set any panel active, you simply need to specify setcommandpaneltaskmode #panel, where panel is one of the six Command Panel tabs: create, modify, hierarchy, motion, display, or utility. Instead of using SETCOMMANDPANELTASKMODE, you can use MAX MODE PANEL, substituting the panel name for panel, just like the previous example.

Transform Tools

You can activate all transform tools using scripts. See Table 17.4 for a list of the commands you can use to activate each transform tool.

Table 17.4 TRANSFORM TOOL COMMANDS
Command Transform Tool
max move Move tool
max rotate Rotate tool
toolmode.nonuniformscale() Non-Uniform Scale tool
toolmode.uniformscale() Uniform Scale tool
toolmode.squashscale() Squash tool
max select Select tool

TOOLMODE commands also allow us to set the active coordinate system and which pivot point will be used. TOOLMODE.COORDSYS will set the active coordinate system, which you need to choose from among #view, #screen, #world, #parent, #local, or #grid.

To set the coordinate system center, you can use the properties of TOOLMODE: .pivotcenter(), .selectioncenter(), or .transformcenter(). These will set the coordinate system center to each object’s pivot, to the center of the selection, or to the origin of the coordinate system, respectively.


Previous Table of Contents Next

© 2000, Frol (selection, edition, publication)

 
Rambler's Top100