Variables

 
 
 

Scripted operators can have variables as well as connections. Variables are custom parameters that belong to the scripted operator and can be used to control its effect. You can edit and animate variables just like any other custom parameter in a scene. In addition, the variable is available to the scripted operator in its calculations.

For example, if you create a custom deformation, you could define a variable to control the amplitude of the deformation. You can then animate the amplitude using keys, expressions, actions, and so on.

You manage variables in a similar way to connections, using the grid in the top pane of the scripted operator editor. To see variables, make sure to select Variables from the list in the upper left.

A

Select Variables.

B

Create a new variable.

C

Remove the highlighted variable.

D

Move the highlighted variable up or down in the list.

E

Name of the variable to use in your code.

F

Data type of custom parameter.

G

Current value of custom parameter (for display only).

Adding New Variables

To add a new variable to control your scripted operator

  1. Make sure that Variables is selected in the list in the upper left of the scripted operator editor.

  2. Click the New button. The Custom Parameter dialog box opens.

  3. Specify a name, data type, default value, value range, and other options for the variable, then click OK. For more details see New Custom Parameter Dialog Box [Properties Reference].

The variable is displayed on a new row in the top pane of the scripted operator editor.

Setting Variable Values

You can edit and animate the values of variables just like any other custom parameter.

To display a property editor with the scripted operator's variables

  • Do one of the following:

    • In the scripted operator editor, click the Inspect button on the command bar.

      or

    • In an explorer, select the Scripted Op node and press Enter.

      Alternatively, choose any other command that displays the custom properties: Edit Properties Custom Properties, Edit Properties General Properties, Edit Properties All Properties, and so on.

      or

    • In an explorer view, click the icon of the Scripted Op node.

Retrieving and Using Variable Values

To use the values of variables in your scripted operators, you must retrieve them. For example:

locVar = In_UpdateContext.Parameters("MyParam").Value
' Do something with locVar

You can also use the shorter form:

locVar = In_UpdateContext.MyParam.Value

Editing Variable Definitions

You can edit the variable definition (name, range, and so on) in the same way as other custom parameters: by marking it then choosing Create Parameter Edit Parameter Definition from the Animate toolbar.

For more information see Editing Custom Parameter Definitions.

Removing Variables

To remove an unnecessary variable from a scripted operator:

  1. Make sure that Variable is selected in the list in the upper left of the scripted operator editor.

  2. Select a connection by clicking anywhere in the associated row.

  3. Click the button.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License