Tips and Tricks for Scripted Operators

 
 
 

Here are a few of tips for working with scripted operators.

Viewing and Accessing Scripted Operators

You can get information about scripted operators on transformation parameters and access them in the 3D views.

Showing Scripted Operator Relations

To see scripted operator relations in a viewport, click the eye icon on the viewport's menu bar and make sure that Relations is on:

  • If the selected object has transformation parameters that are driven by scripted operators, the label Scop is displayed in white to the right of the object's center.

Click on the label to see a list of the parameters that are driven by scripted operators. Click on a parameter in the list to open the scripted operator in the editor.

  • If the selected object has transformation parameters driven by scripted operators that involve other objects as input connections, those objects are linked to the selected object by dotted white lines.

    You can click on a dotted line to see a list of transformation parameters that involve the linked object. You can also click on one of the parameters in the list to open the scripted operator in the editor.

Animation Cues and Scripted Operators

To show animation cues in a viewport, click the eye icon on the viewport's menu bar and make sure that Animation Cues is on.

If the selected object has transformation parameters that are driven by scripted operators, a red triangle appears to the right of the object's center.

Click the triangle to see a list of transformation parameters that are driven by scripted operators, and click a parameter in the list to open the scripted operator in the editor.

For more information about animation cues in general, see Visual Cues for Animated Transformations [Animation].

Applying Scripted Operators on Colors

You cannot use the animation icon to set a scripted operator on an R, G, or B color channel. Instead, you can do either of the following:

  • Mark the color and choose Animation Set Scripted Operator.

    or

  • Right-click on the color channel in an explorer and choose Set Scripted Operator.

Testing for Scripted Operators

To test whether an object has a scripted operator on a parameter with a script, use the IsAnimated command:

bHasScrOp = IsAnimated(oMyObj, siScriptedOperatorSource, , )

With the object model, you can use the IsAnimated method:

bHasScrOp = oMyObj.IsAnimated(siScriptedOperatorSource)

Getting the Current Frame

To get the current frame, use the In_UpdateContext.CurrentFrame property. For example:

logmessage "Evaluating MyOp at frame: " & In_UpdateContext.CurrentFrame

You can also make an input connection to PlayControl.Current — that is the method that was used in previous versions before In_UpdateContext.CurrentFrame was available.

Forcing Updates

Normally, scripted operators are updated only when their input connections change values. To force your scripted operator to update at every frame change, click its icon in an explorer and activate Always Update.

Muting Scripted Operators

To mute a scripted operator, click its icon in an explorer and activate Mute.

Debugging Scripted Operators

To display messages in the command history to help debug scripted operators, click its icon in an explorer and set Debug. Higher values display more verbose messages.

Using Global Variables to Optimize Speed

By declaring variables globally in the bottom pane of the scripted operator editor, you can improve the performance of your scripted operators.

Be careful to avoid name collisions between different operators as described in Subroutines, Variables, and Name Collisions.

Getting More Information Objects, Properties, and Methods

Reference information about the objects, properties, and methods available in the object model, as well as about scripting commands, is available in the SDK Guide.

To display this information, press F1 or choose Help Scripting Reference from the command bar of the scripted operator editor. Methods and properties that you can use in a scripted operator are marked with an asterisk.