|
i n t r o d u c t i o n
Slim Ribbox Scripting I provided a couple of simple
examples of using TCL expressions in a ribbox. This page provides examples of
ribbox scripts that make more extended use of TCL.
[ # calculate one or more values using the TCL expr # procedure ie. # set foo [expr math_function] # # use the TCL return procedure to output one or # more RIB statements ie. # return "RIB_Statement $foo" ] |
|
example 1 - setting a surface color In this example the slim predefined variable "$pct" is used to set a (grayscale) color based on the sine function. Because the sine function generates values from -1 to 1 the abs() function is used to ensure positive values are assigned to the RIB "Color" statement.
ribbox listing 1 |
figure 1 |
|
example 3 - using a custom string attribute to access a prebaked rib
(mel) listing 3 The attribute is added to the shape node rather than the transform node so that the TCL script embedded within in the ribbox is able to (more conveniently) access the attribute using slim's built-in "clientcmd" procedure.
ribbox listing 4
The advantage of this approach is that the assignment of a pre-baked rib to a
proxy object, say a cuble, can be controlled from the Maya attribute editor.
As a consequence a single ribbox, containing the code shown in listing 4, can
be attached to several proxy objects. Normally, each proxy object must be assigned
its own ribbox that in turn references a specific pre-baked rib.
|
![]() figure 3 |
|
example 4 - assigning a TCL expression to a shape node
(mel) listing 5 Using the "attribute editor" the following text is entered into the "tcl" attribute, clientcmd "getAttr $OBJPATH.fval" A ribbox containing the following TCL script is attached to the cube,
ribbox listing 6 The result of the eval'uation of the short TCL script contained in the "tcl" attribute will be to insert the following text into the output RIB file. In itself this example does not perform any useful task. However, it does demonstrate the fact that Slim's predefined variables ($OBJPATH for example) can be used in the text of an "external" TCL script that is evaluated somewhat indirectly within the Slim TCL context of a ribbox. #slim ribbox RIBBox_5 0.2 <--- result of "indirect" evaluation |
© 2002-5 Malcolm Kesson. All rights reserved.