Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following topics explain how to retrieve data with scripts:toc

Scroll only
scroll-viewporttrue
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-htmltrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue

Work with ranges

You can write a script to retrieve animation and scene ranges. This is useful when you want to limit an editing operation to only the active range or when you want to make sure you apply and operation to all the frames in a scene.

Import the required Shogun file. Set a playRange using the playback bar to start, say, at frame 50 and end at frame 65. Select and copy one of the examples below, then paste it into the Shogun Post Script Editor. To execute the script, click the Run button .

Code Block
languagetext
// Assign the variable $ animStartFrame to the animation start frame

...


// as retrieved by the command getAnimStart;

...


int $animStartFrame;

...


$animStartFrame = ` getAnimStart`;

...


 
// Print the animation start frame as part of a sentence

...


print ( "The animation start frame is frame " + string ($animStartFrame ) );

...


 
// Create a variable called $animEndFrame and assign it the

...


// value of the animation end frame as retrieved by the

...


// command getAnimEnd;

...


int $animEndFrame;

...


$animEndFrame = `getAnimEnd`;

...


print( "The animation end frame is frame " + string( $animEndFrame ) );

...


 
// Identifies the incoming scene playRange and animation Range

...


playRange -save;

...


 
// This statement just prints the result of getPlayStart

...


// getPlayEnd as part of a statement

...


print( "The playRange is " + string (`getPlayStart`) + " to " + string (`getPlayEnd`) );

Scroll pagebreak

Get the length of a bone

You can write a script to calculate and display the length of a bone. This is handy when you need a script to fit custom skeletons to markers or scale skeletons up and down.

Code Block
languagetext
// getLength just tells you what the length of any vector is.
// It's not a bone-specific command though it's useful for working 

...


// with bones.
// Get selected bone
string $bones Array] = `getModules -selected `;

// Set the offset of that bone as a vector
vector $source = `getVectorProperty $bonesArray[0] Translation`;

// Translate that vector into a float value
float $length = `getLength $source `;
print (strongylosis));

Determine script execution time

...

Before you execute this script you must load a suitable Shogun file.

Code Block
languagetext
//Script timer------------------------------------

...


 int $sysTimeStart = `getSystemTime`;

...


 int $sysTimeEnd;

...


 string $sysTimeString = (`formatTime $sysTimeStart`);

...


 print ("Script started on " + $sysTimeString); 

...


 //Script timer------------------------------------

...


 // Insert a nested script or specific script commands below

...


 selectByType Marker;

...


 selectProperty Translation;

...


 selectRange -all;

...


 fillGaps -all;

...


 filter 0.1 35; 

...


 //Script timer End---------------------------------

...


 print ("Script started " + $sysTimeString);

...


 $sysTimeEnd = `getSystemTime`;

...


 $sysTimeString = (`formatTime $sysTimeEnd`);

...


 print ("Script ended " + $sysTimeString); 

...

 //Script timer End---------------------------------

Scroll pagebreak

Determine which executable file is running

...