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

Previous Table of Contents Next



NOTE If you do not switch to the Modify tab, all options will be recorded in a single MAXScript line. The final result is the same, but it will be more difficult to edit the script in the future.

Play the animation and see the bubbles going up. Let’s create a script to automatically create this bubble particle.

1.  Select the lines you have just recorded in the Macro Recorder pane and drag them to the particles Tab, as shown in Figure 13.3. This automatically creates the script for you. Note that your script has been sequentially named (Macro1, Macro2, etc.).
2.  Reset MAX using FileØReset.
3.  Click the button you just created, and MAX will create the same object you did before.


FIGURE 13.3  Dragging a script to the particles Tab (note the cursor location)


NOTE Everything that you type in the Listener or record using the Macro Recorder can be dragged to a toolbar or to a Tab, where it will automatically create a button. This button makes it easier to use the script because you can just click it to repeat the action. The script created from a drag-and-drop operation will be stored in the \UI\Macroscripts folder.

The script repeats the exact steps used for this object, which means the object will always be created in the same position. You might want to create the object and insert it anywhere, just like any other new object in MAX. Let’s edit the script and add some options to do this.

1.  Right-click the new button and select Edit Macro Script, bringing up a MAXScript editing window.
2.  Add this line just before the superspray command:
pt = pickpoint prompt:”\nSelect Position:”

Your script window should now look like the one in Figure 13.4.

NOTE The PICKPOINT command asks for a point to be clicked on screen, or a location to be typed in X, Y, Z format. The position will be assigned to the pt variable.

TIP When using strings, add \n to start in the next line.


FIGURE 13.4  Editing the Macro Script

3.  Locate the pos:[...] statement in the superspray line, and change it to pos:pt.
4.  Evaluate the script, selecting FileØEvaluate All in the script editor menu, and save it. Nothing will happen here, but you will see the difference the next time you insert the object. Click the button and create more bubbles. Notice that now you have the option to select where you want each object.
5.  Close the script.
6.  Right-click the button and select Edit Button Appearance.
7.  Select Text Button and type Bubbles as in Figure 13.5.


FIGURE 13.5  Editing the button appearance

8.  Type the same text in the Tooltip, and click OK. Notice you now have a text button, and it has a tooltip.

Using this exercise, you learned how simple it is to record an action and create a script with it. You also learned how to interact with the script and wait for user input.


TIP You can also select an image icon for the button. MAX comes with a huge number of button icons already created, one for each object and modifier; a small sample is shown in Figure 13.6. You can also create your own icons with the MakeIcon sample script that comes with MAX. This script is located in Scripts\Utilities.


FIGURE 13.6  Pre-installed button icons

Using the Macro Recorder

The Macro Recorder is one of the most important new features in MAX R3. It records all scriptable actions you do in MAX and outputs in the script format. You can use it not only to create scripts directly using drag and drop, but also to create scripts using the commands you need without the need to memorize those commands.

You can configure the Macro Recorder by selecting the MacroRecorder menu in the Listener. You can configure MAXScript to record actions absolutely, which means in real-world PRS (Position, Rotation, and Scale) to a specific, named object; or relatively, which means relative to the actual PRS or the active selection. As an example, if you had all options as absolute, moving an object called Sphere01 would record the following line:

$Sphere01.pos = [10,10,10]

If you had all options as relative, it would record the following line:

move $ [-10,0,0]

If you use $sphere01 in a script, it will only work if an object exists with that specific name. This is not a common situation in scripting, since you want the flexibility to apply the script to many different objects and situations.


TIP Always have the Macro Recorder configured for Relative and Selections. This way you can reuse your scripts, independent of the name of the objects and their location in the scene. If you configure for Absolute, you will not be able to reuse your scripts in other objects, but only in the objects you had when you recorded.

In the Macro Recorder area of the Listener, you can save what has been recorded. When this file is loaded using the FileØRun Script command, it will repeat all the steps you have recorded. This way you can record information to be used in other scripts, as we will do in many exercises in Chapter 14.

Macro Recorder Limitations

The Macro Recorder records only actions that are exposed to MAXScript. Here’s a list of some objects and functions that are not exposed:

  Compound objects, except Shapemerge and Terrain (which have limited support)
  NURBS curves and surfaces
  Line Shape
  Systems
  Anything in the Command Panel’s Hierarchy tab
  Anything in Track View, except Controllers and Keys manipulation
  Anything in Video Post
  Render Scene dialog changes
  Array, Align, Spacing, Place Highlight, Mirror, Snapshot, etc.
  Anything in the Utility tab
  Commands in Editable Mesh, Spline, Patch, and NURBS (move/rotate/scale are recordable)
  Controller dialogs (like Noise Controller, Waveform Controller)
  Changes made to keys in Motion/Trajectories
  Hide/Freeze by Name and Hide/Freeze by Hit
  Display Color, Hide by Category, and Link Display
  Most rollout items in the Display Properties rollout in the Display tab
  Linking/unlinking in Schematic view


Previous Table of Contents Next

© 2000, Frol (selection, edition, publication)

 
Rambler's Top100