
v4.0
Sets or returns the script code used by the runtime custom
operator implementation as a String.
Note: This can be used for either runtime (when the definition of
the custom operator is contained within the scene and not saved on
file) or for SPDL-based scripted operators. However, if you use
this on a custom operator which is compiled, an empty string is
returned. This property is not meaningful for Self-installed Custom
Operators.
You can read this property from within the update function of a
custom operator but setting this property is blocked.
// get accessor String rtn = CustomOperator.Code; // set accessor CustomOperator.Code = String; |
NewScene( null, false );
var null1 = GetPrim("null");
var sop = null1.posx.AddScriptedOp( MyExpr_Update.toString(), null1.posy, "MyExpr", "JScript" );
// Log the evaluated of posx
val = GetValue(null1.posx,1);
Application.LogMessage( "first evaluated value " + val );
var code = sop.code;
// Change the code
var re = /ctx.CurrentFrame/g;
sop.Code = code.replace( re, "2" );
// Change the input value
SetValue( null1.posy, 100 );
// Log the new evaluated of posx
val = GetValue( "null.kine.local.posx" );
Application.LogMessage( "new evaluated value " + val );
function MyExpr_Update(ctx,out,in1)
{
Application.LogMessage( "MyExpr_Update: " + out.name );
out.Value = ctx.CurrentFrame;
}
|