You can maximize your efficiency and reduce the time it takes you to complete projects by creating scripts. Most people use Shogun Post to repeatedly perform the same types of tasks. Taking three hours to create a great script for performing a task that would only take you half an hour is a good investment— if you use the script just six times, it has paid for itself. If you use it a hundred times you have saved yourself almost a week of production time. Scripting is even more critical when you work with several motion capture professionals. Scripts enable you to ensure that all data is handled the same way by all operators, resulting in consistent data.

To be really useful, however, your scripts must be readable, easy to customize, and bulletproof. This page contains suggestions for creating scripts and how to fix common bugs that and your associates may come across. This allows you to spend less time looking for bugs and more time producing high quality motion capture animation.

Use spacing

Using the right spacing and indentation makes your scripts easier to read, easier to use, easier to customize. Spacing does not affect the execution of a script, so you can use as many spaces, line breaks, and tabs as you like.

Tip
You must insert at least one space between keywords and variables.

The following is an example of a poorly spaced script. As you can see, it is difficult to understand the structure of the script, to identify the variables, or to figure out what the script does.

if ( ( `getCount $ selectionArray ` ) == 2 ){
vector $source1 = $selectionArray[0].Translation; vector $source2 = 
$selectionArray[1].Translation; vector $position = ( $source2 - $source1 );
float $distance = `getLength $position `; print ( "The distance between " + (
 string ($selectionArray[0]) ) +" and " + ( string ($selectionArray[1]) ) + " is " + ( string ( $distance ) ) + "mm ." );
} if ( ( `getCount $ selectionArray ` ) != 2 )
print "Must have exactly 2 nodes selected."; $text = "Default scaling";

Here is the same script that is easier to read with improved spacing:

if( ( `getCount $selectionArray` ) == 2 )
{
vector $source1 = $selectionArray[0].Translation;
vector $source2 = $selectionArray[1].Translation;
vector $position = ( $source2 - $source1 );
float $distance = `getLength $position `;

print ( "The distance between " + 
( string ($selectionArray[0]) ) +
" and " + ( string ($selectionArray[1]) ) +
" is " + ( string ( $distance ) ) + "mm ." );
}
else
{
print "Must have exactly 2 nodes selected.";
}
$text = "Default scaling";

Each command statement is on its own line. The If/Then loop elements are on their own lines. Variables are defined on their own lines. Print statements are structured so you can see at a glance what elements are being assembled. Take time to format scripts whenever you create them. You will find that the investment pays off the very next time you need to use them.

Add comments

HSL scripts without comments are like city maps without street names. They might take you somewhere, but you can not be sure it will be where you want to go.

Add comments to your scripts so it is easy for you and for others to understand what each section of the script does, and what data can be changed. To add a comment to a script, just put two forward slashes at the start of the comment line //.

// Default locator number is lucky.
 int $locator = 7;
 // Select the head markers and make a rigid body

Use a naming convention

If you develop and use some kind of consistent strategy you routinely use for defining variables and naming objects, you will save yourself hundreds, if not thousands, of hours of debugging time.
Follow these suggestions to use a convention to name variables and objects logically and concisely: