Creating a Qt Script

Use the Script Editor to create Qt scripts for Harmony.

This topic is divided as follows:

Creating a Script
Deleting a Script
Troubleshooting a Script

Creating a Script

To create a script:

1. Open the Script Editor by going to the top menu and selecting Windows > Script Editor.

The Script Editor view opens listing all the JavaScript files.

Script Editor Window

2. From the View menu View Menu Button select File > New Script or from the Script Editor toolbar, click on the New Script New Script Button button. (If you do not see the Script Editor toolbar, go to the top menu and select Windows > Toolbars > Script Editor).

The New Script dialog box appears.

New Script Name Window

3. Enter a name in the Enter name of new script field and click on OK.

The Save Script window opens.

Save Script Window

4. To save the script:
Click on the User button to store the script into the user profile so the user can always access the script (/usa_db/users/user_name).
Click on the Global button to make the script available to all users from any scene, job and environment (/usa_db/scripts).
Click on the Environment button to make the script available to all users when working in a scene from this particular environment (/usa_db/environments/environments_name).
Click on the Job button to make the script available to all users when working on scenes from a particular job (/usa_db/jobs/job_name).

The name of your script appears in the File column of the Script Editor view.

Script and File List in Script Editor Window

5. Click in the right side of the Script Editor and start writing your script. Try typing in the following script:

function add3dPathCol()

{

column.add(“ColumnName”, “3DPATH”);

}

For a tutorial on coding in JavaScript, refer to the following:

http://docs.oracle.com/javase/tutorial/java

For a detailed Harmony script interface documentation, refer to the following:

Harmony Script Interface Documentation
6. To check your syntax, click on the Verify button.

A window opens with syntax information.

Syntax Check Pop-up Window

7. To test your script, select the function you would like to run from the File column, then, from the Script Editor toolbar, click on the Run Run Script Button button, or from the View menu View Menu Button select Play/Debug > Run.
A window opens to ask you for the target function to run. In the window, select which function you want to execute. To avoid selecting the function every time you want to run your script, you can set a target function. In the Script Editor toolbar, click on the Set TargetSet Target Function Button button, or from the View menu View Menu Button select Play/Debug > Set Target. In the Function column, select the function to target and press OK.

Set Target Function Window

To stop the execution of your script, click on the Stop Execution Stop Script Execution Button button.
You may receive the message: Only functions that have been saved or are explicitly called will be executed. This usually occurs if you did not select the function you wished to run from the File column before running the script. In this case, click on the Save Changes button, then try running your script again.
You may also see this message on the right side of the Script Editor:

Script Editor Sandbox Message

This is because the software jumped to the <<Sandbox>> item in the Function column. The <<Sandbox>> is provided to test scripts without saving them. Simply click on your newly created script and then try running it again.

A new 3Dpath column (or 3 separate x, y and z path columns and a velocity column) will appear in your Xsheet view with the name ColumnName.

You should back up your scripts if they are placed at the Global location because every user opening a scene gets the rights to them and if a problem arises it can corrupt the saved scripts.

Deleting a Script

To delete a script:

1. In the Script Editor, in the File column, select the script that you would like to delete.
2. From the Script Editor toolbar, click on the Delete Script button or from the View menu , select File > Delete Script.

Troubleshooting a Script

To troubleshoot errors in your script:

1. Debug: In the File list, select the script containing the function to debug.From the Script Editor toolbar, click on the Debug button, or from the View menu , select Play/Debug > Debug.

A window opens listing the scripts and functions available.

Script Debugger Function List Window

2. In the Functions column, select the function to debug.
3. Click on the OK button.

The Qt Script Debugger opens.

QT Script Debugger Window

Related Topics 

Harmony Server Network Environment
Using Qt Script to Automate Toon Boom Harmony Functions - server functions
Importing Scripts
Linking a Script to a Toolbar Button