Laying out a Rollout


The rollout space, which appears gray in the left pane, can be selected and resized by dragging the black square handles at the edges of the form. As you change its size, its dimensions are displayed in the lower-right corner of the interface. With the rollout space correctly sized, you are ready to add elements to the space.

To add one of these elements to the form, click the element button on the toolbar and drag on the form. The element appears and is selected. The selected element is easy to identify by the black handles that surround it. Dragging on these handles resizes the element, and clicking and dragging on the center of the element repositions it within the rollout space.

The Value and Events panels are automatically updated to show the values and events for the selected element. Values such as width and x-pos are automatically updated if you drag an element or drag its handles to resize it.

Aligning and spacing elements

Although only one element at a time can be surrounded by black handles, you can actually drag an outline in the rollout space to select multiple elements at once. With several elements selected, you can align them all to the left (Ctlr+left arrow), horizontally centered (Shift+F9), right (Ctrl+right arrow), top (Ctrl+up arrow), vertically centered (F9), or bottom (Ctrl+down arrow).

Multiple elements can also be spaced across (Alt+right arrow) or down (Alt+up arrow). To make several elements the same width, height, or both, use the Layout image from book Make Same Size menu command. The Center in Dialog menu aligns elements to the center of the dialog box either vertically (Ctrl+F9) or horizontally (Ctrl+Shift+F9). The Flip command reverses the position of the selected elements.

Figure 49.18 shows a form with several aligned elements added to it.

image from book
Figure 49.18: You can add control elements to the form in the Visual MAXScript window.

Tutorial: Building a custom rollout with the Visual MAXScript Editor

Now you need some practice using this powerful tool. In this example, you use the Visual MAXScript window to lay out a rollout and code the script to make it work.

To create a custom rollout using the Visual MAXScript Editor, follow these steps:

  1. Open the image from book BuildCube.max file from the Chap 49 directory on the DVD.

    This file includes a simple sphere object.

  2. Choose MAXScript image from book New Script to open the MAXScript Editor window. In the editor window, enter the following:

          utility buildCube "Build Cube" ( ) 

    This line creates a utility named buildCube. The rollout name is Build Cube. Make sure to include a space in between the parentheses.

  3. Choose Edit image from book New Rollout from the window menu (or press the F2 key). The Visual MAXScript window opens. The properties for this rollout are displayed in the Properties panel. Drag the lower-right black square handle to resize the rollout form.

  4. Click the spinner button on the bottom toolbar, and drag in the rollout form to create a spinner element. In the Properties panel, set the name to SideNum, set the caption value to No. of Side Objects, select the #integer for the type, and set the range to [1,100,5]. The range values set the lower, upper, and default values for the spinner. Then drag the element handles to resize the element to fit in the form.

  5. Click the spinner button again, and drag in the rollout form to create another spinner element. In the Properties panel, set the name to length, set the caption value to Side Length, select the #integer for the type, and set the range to [1,1000,50]. Then drag the element handles to resize the element to fit in the form.

  6. Click the button icon on the bottom toolbar, and drag in the rollout form to create a button below the spinners. In the Properties panel, set the name to createCube and the caption value to Create Cube. Then drag the element handles to resize the button so the text fits on the button. Open the Event Handlers panel, and select the Pressed check box.

  7. Drag over the top of both the spinners to select them both, and choose Layout image from book Align image from book Right (or press Ctrl+right arrow) to align the spinners. Figure 49.19 shows how the rollout layout looks.

    image from book
    Figure 49.19: The rollout laid out in the Visual MAXScript window

  8. With the layout complete, choose File image from book Save (or press Ctrl+S) to save the layout, and then close the Visual MAXScript window.

    The script code associated with the layout is automatically placed in the editor window.

  9. Complete the script by entering the script commands immediately after the open parenthesis that appears on the line following the on createCube pressed do event, as shown in Figure 49.20. Then, copy and paste the code from the image from book BuildCube.ms file from the Chap 49 directory on the DVD.

    image from book
    Figure 49.20: The MAXScript Editor window is updated with the code from the Visual MAXScript window.

  10. Open the Utilities panel, and click the MAXScript button. Then click the Run Script button, and select the image from book BuildCube.ms file from the Chap 49 directory on the DVD.

    The utility installs and appears in the Utility drop-down list in the MAXScript rollout.

  11. Select the BuildCube utility from the drop-down list in the MAXScript rollout, and scroll down the Command Panel to see the Build Cube rollout. Select the sphere object, and click the Create Cube button.

    The script executes, and a cube of spheres is created.

Figure 49.21 shows the results of the image from book BuildCube.ms script. You can use this script with any selected object.

image from book
Figure 49.21: The results of the BuildCube.ms script




3ds Max 9 Bible
3ds Max 9 Bible
ISBN: 0470100893
EAN: 2147483647
Year: 2007
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net