Your Ad Here

Editing Scripts

Appropriately, you edit scripts in the script editor. The script editor is a text-editing window where you can create, modify, run, and manage scripts. The script editor includes a command bar, history pane, and editing pane.

 

 

You can resize the history and editing panes relative to each other by clicking and dragging on the bar that separates them. Click the triangle on the splitter bar to hide the history pane, and click it again to restore the history pane.

To open the script editor

Do one of the following:

• Click the script editor icon on the Scripting panel at the bottom of the main window.

 

or

• Press Alt+4.

or

• Choose View > Scripting > Script Editor from the main menu.

Editing Scripts

To create and edit a script, use the editing pane as you would any other text editor. You can cut, copy, paste, move, and type text. Use the history pane as a source for dragging-and-dropping text or as a reference for command names and syntax.

Working in the Script Editor

One important thing to remember when editing scripts is to keep the mouse pointer over the script editor window; otherwise, your keystrokes are interpreted as commands in the viewports or another XSI window.

Commands in the Script Editor

As you work in the script editor, you can use the commands and options in the Edit and View menus on the command bar as well as in the pop-up menu that appears when you right-click. You can also use standard mouse and keyboard commands:

To do this...

Do this

Select the entire contents of the editing pane.

Ctrl+a

Select a word in the history or editing pane.

Double-click on the word.

Select a line in the history or editing pane.

Triple-click on the line.

Move selected text.

Drag to new location.

Copy selected text.

Ctrl+drag to new location.

Cut selected text to the clipboard.

Ctrl+x

Copy selected text to the clipboard.

Ctrl+c

Paste text from the clipboard.

Ctrl+v

Undo the last edit.

Ctrl+z or Alt+Backspace

Redo the last undo, or repeat the last edit.

Ctrl+y

Go to the next/previous word.

Ctrl+right/left arrow

Go to the beginning of the script.

Ctrl+Home

Go to the end of the script.

Ctrl+End

Extend the selection.

Shift+arrow keys,
Ctrl+Shift+arrow keys

Select from the cursor to the beginning of the line.

Shift+Home

Select from the cursor to the end of the line.

Shift+End

Select from the cursor to the beginning of the script.

Ctrl+Shift+Home

Select from the cursor to the end of the script.

Ctrl+Shift+End

Toggle overtype mode on or off.

Insert

 

If the text you type overwrites existing text, it’s probably because you have accidentally pressed the Insert key. Press the Insert key again to turn overtype mode off.

Finding and Replacing Text

You can find and replace text in the editing pane:

• To open the Find in Editing Pane dialog box, choose Edit > Find or press Ctrl+f.

• To open the Replace dialog box, choose Edit > Replace or press Ctrl+h.

Clearing the Editing Pane

To clear all text from the editing pane, choose Edit > Clear Script Editor.

 

Clear Script Editor does not start a new script file. If a saved script file was open and you clear the editing pane, you will replace the file on disk if you save it instead of choosing File > Save As.

To start a new script, click the New button or choose File > New.

Using the Command History

The history pane contains the most recently used commands in your current session. It also displays any logged messages — information, warnings, and errors. In addition, it displays syntax errors from the scripting engine when you run scripts.

You cannot edit the text in the history pane, but you can use it as a source for dragging and dropping or pasting into the editing pane. You can clear all the lines in the history pane, and set the number of lines kept in the history.

Clearing the History

After you have been working in XSI for a while, the history pane becomes cluttered with old commands and it may be useful to clear it. For example, this would let you make changes to a scene and then copy all the logged commands to the editing pane, rather than scrolling through the history to see which lines you wanted.

To clear the history pane

Do one of the following:

• Choose Edit > Clear History Log.

or

• Right-click in the history pane, then choose Clear All.

Setting the Size of the History

By default, the history pane keeps the last 200 commands, but you can change this number in your preferences. Changing this value usually does not have a significant effect on XSI’s memory consumption or performance.

To set the number of commands in the list

1. Open the Preferences window by choosing File > Preferences from the main menu.

2. Click Scripting.

3. Specify the maximum number of lines under Command Log > Log Size or select the Unlimited option.

Using Logged Commands and Immediate Mode

If you want to be able to replay commands from the history, don’t use immediate mode when issuing commands through the XSI interface. When you get a primitive or apply an operator in immediate mode, the corresponding property editor opens with OK and Cancel buttons.

If you change a parameter value while the property editor is open, no SetValue command is logged. As a result, you will get different results when you play back commands from the history.

Disabling and Enabling Command and Message Logging

You can disable and enable the logging of commands and messages to the history pane. Disabling logging may speed up the performance of XSI somewhat.

As an alternative to this procedure, you can turn off logging temporarily while running a script — see Disabling Command Logging Temporarily.

To disable or enable command or message logging

1. Open the Preferences window by choosing File > Preferences from the main menu.

2. Click Scripting and activate or deactivate these options:

- Log Commands

- Log Messages

The Command Log

In addition to maintaining a history of commands used in the current session, you can save a log of commands to disk. This feature is sometimes called journaling.

You can use the command log for a variety of purposes. For example, if you imported a scene from SOFTIMAGE|3D or another program to apply textures and lighting before you animated the scene, you can copy the contents of the log into the script editor to help redo your XSI commands after the scene is animated.

 

If you want to keep a log file, make sure you rename it before you restart XSI. You cannot access the file while XSI is running, and the file is overwritten once you begin working in a new XSI session.

To activate logging

1. Open the Preferences window by choosing File > Preferences from the main menu.

2. Click Scripting and select the Log to File option.

3. You can also specify a path and file name in the Log File text box.

Managing Script Files

The first time you open the script editor, the editing pane is empty. Once you have added commands to create a script, you can save the contents of the editing pane as a script file. The script editor also lets you open existing script files and create new ones.

Scripts are saved as plain text files with an extension that denotes the scripting language. For a description of the supported scripting languages, see Scripting Languages.

Where Script Files Are Stored

Although you can save script files anywhere, it is recommended that you use a standard location. This makes it easier to keep track of your scripts, especially when editing and updating them. The default location is the Data\Scripts subdirectory of your user path.

The Paths button in the Open and Save Script File browsers lets you quickly choose between various base locations, including:

Installation (Factory) is the location where the XSI program files are installed. Scripts saved here are available to any user on the local machine. You will need to copy these scripts if you install XSI to a new location.

Workgroup lets you share scripts, presets, and other data with members of your team.

User is your user path, for example, C:\users\username\Softimage\XSI_4.0. Scripts saved in this location are available to you whenever you are logged in as the same user on that installation of XSI.

Sample Project is a project with sample scenes included with XSI. It is not recommended to save your scripts here.

Current Project is the project that contains the open scene. You could use this folder if your script is specific to a particular project.

Factory Add-ons is the Addons subdirectory of the location where the XSI program files are installed. It is not recommended to save your scripts here.

User Add-ons is the Addons subdirectory of your user path. You can store scripts in separate subdirectories here to keep them organized.

Workgroup Add-ons is the Addons subdirectory of your workgroup path. As withe the user add-on path, you can store scripts in separate subdirectories here to keep them organized.

• Other projects in your Projects List are listed under Projects.

Note that there is a Scripts folder in every project. This is a good location in which to save a script if it is very specific to a particular project or scene, or if you want to make sure that the correct version of a script is stored with a project for the purpose of archiving.

Saving Script Files

You can save either the entire contents of the editing pane, or just the selected text.

To save the entire contents of the editing pane to disk as a script file

Do one of the following:

• Click Save on the command bar.

or

• Choose File > Save from the command bar.

or

• Press Ctrl+s.

If the script has not been saved before, the Save Script File browser prompts you to specify a file name and folder. You should also make sure that the extension is the correct one for the language of the script.

Once you supply a file name for the script, the name is displayed in the title bar of the script editor window.

To save the entire contents of the editing pane with a new name

• Choose File > Save As from the command bar.

The Save Script File browser prompts you to specify a file name, folder, and extension.

To save selected text as to disk as a script file

1. Select some text in the editing pane.

2. Choose File > Save Selection from the command bar.

The Save dialog box prompts you to supply a file name. You should also make sure that the extension is the correct one for the language of the script.

Opening Script Files

You can open a saved script from the script editor’s File menu or by dragging and dropping. You can also open a script that has been registered as a custom command directly from its command button.

 

If you open a script file in a different language, it automatically changes the scripting language that is set in your preferences.

To open a script from the File menu

1. Display the Open dialog box by doing one of the following:

- Choose File > Open from the command bar.

or

- Press Ctrl+o.

2. If the current contents of the editing pane have not been saved, you are prompted to save them. Click Yes or No as desired.

3. Use the Open Script File browser to select a script file and click OK.

The contents of the script file are displayed in the editing pane, and the name of the file is displayed in the script editor’s title bar.

To open a recent script

• Choose the script from the File > Recent Scripts menu.

To open a script by dragging and dropping

• Drag the script file from a browser view into the editing pane, or drag a link to the script file from Net View.

On Windows, you can also drag it from a folder window.

To open a script that has been registered as a custom command

• Right-click on the command button in a custom toolbar and choose Edit Script. Alternatively, if the script editor is already open, you can drag the button into the editing pane.

Starting New Script Files

Do one of the following:

• Click the New button on the command bar.

or

• Choose File > New from the command bar.

or

• Press Ctrl+n.

When you create a new script file, you are prompted to save the contents of the editing pane. After you have clicked Yes or No, the editing pane is cleared and the name of the script is displayed as Untitled in the script editor’s title bar.

 

In the script editor, you can also clear the contents of the editing pane by choosing Clear Script Editor from the Edit menu. However, this does not change the name of the script as displayed in the title bar of the script editor. Accidentally choosing Save instead of Save As would then overwrite the named file on disk.



SOFTIMAGE|XSI v.6.01     

Return to Softimage XSI Index


Your Ad Here