Scripts

From ShadeCamp

Jump to: navigation, search

Scripts give you the power to customize objects, lights, cameras, windows, and just about everything else that is used in Shade. Use scripts to set a particular parameter or to get the parameter’s value. Scripts can also be used to combine several commands into one, saving you time and work.Using several scripts in combination can even provide additional functionality to Shade.

Contents

The Script Window

Scripting is done in the Script window. Choose View > Script to display the Script window. The Script window is basically a simple text editor for writing scripts in a programming language.

Creating Scripts

To create scripts in Shade you can either write your own or record a sequence of operations in Shade.

Writing Your Own Script

You can write your own script using one of two programming languages that Shade recognizes: Python: Windows & Mac OS X AppleScript: Mac OS X only Note: AppleScript can only be used in Mac OS X’s script editor.

  • Python: Windows & Mac OS X
  • AppleScript: Mac OS X only

Note: AppleScript can only be used in Mac OS X’s script editor.

You can write scripts in the Script window, or use a different text editor. Save your script by clicking the Save button on the right side of the Script window. A File Save dialog appears, allowing you to specify a name for your script. To load a previously saved script, click the Load button (next to Save) in the Script window.

Recording Shade Operations

Many Shade operations can be recorded as scripts. Even if you are not very familiar with programming languages, you may be able to create a very useful script simply by recording a sequence of Shade operations. To start recording to a script, click the Record checkbox in the top left corner of the Script window.

1. Open a new scene by choosing File > New.

2. Create a sphere and extruded closed line similar to those in the image below, and arrange them as shown.

3. If the Script window is not already visible, display it by choosing View > Script.

4. With only the sphere selected in the Browser, check the Record checkbox in the Script window.

5. Choose Translate from the Move tool in the Toolbox, and move the sphere ten grid units in the negative X direction. The Move operation is recorded as a script in the Script window.

6. Now choose Scale from the Move tool, and enlarge the sphere in the X direction. The Scale operation is added to the script.

7. Uncheck the Record checkbox in the Script window to end the recording process.

8. Select the extruded closed line in the Browser.

9. Click the Run button in the Script window. The operations recorded for the sphere (Translate and Scale) are now applied to the extruded closed line.

Running Scripts

There are two main ways to run scripts:

  • Click the Run button in the Script window.
  • Select the script you wish to run from the

Script menu.

From the Script Window

With the script you wish to run displayed in the Script window, click the Run button. This method works well if you wish to run the same script several times with variables set to different values.

From the Script Menu

Scripts that you use often can be saved in the “scripts” folder within the Shade program directory to make them accessible from the Script menu.

1. Click the Save button in the Script window to save the script you just recorded with the Translate and Scale operations. The Save As dialog appears.

2. Navigate to the “scripts” folder inside your Shade program directory.

3. Enter an appropriate name for your script. For the file type, use the default Python script type (*.py).

4. Close and re-launch Shade.

5. Select the Script menu, and verify that your newly saved Python script is listed in the menu. |