/*
This example illustrates how to create parameters from a parameter definition.
*/
var o = ActiveSceneRoot.AddCustomProperty("MyProperty");
var param1 = o.AddParameterFromDef(XSIFactory.CreateParamDef2("text", siString, "text string"));
var param2 = o.AddParameterFromDef(XSIFactory.CreateParamDef2("bool", siBool, true));
var param3 = o.AddParameterFromDef(XSIFactory.CreateParamDef2("int", siInt4, 10, 0, 100));
var param4 = o.AddParameterFromDef(XSIFactory.CreateParamDef2("dbl", siDouble, 0.5, 0.0, 1.0));
var param5 = o.AddParameterFromDef(XSIFactory.CreateFCurveParamDef("fc"));
var param6 = o.AddParameterFromDef(XSIFactory.CreateGridParamDef("grid"));
// list parameters
var eParams = new Enumerator(o.parameters);
for ( ; !eParams.atEnd(); eParams.moveNext() )
{
var param = eParams.item();
var strVal = ""+param.value;
logmessage( param.name + ", " + vt2string(param.valuetype) + ", " + (strVal=="" ? "none" : strVal) );
}
//INFO : Name, wide string, MyProperty13
//INFO : text, string, text string
//INFO : bool, boolean, true
//INFO : int, long, 10
//INFO : dbl, double, 0.5
//INFO : fc, object, FCurve
//INFO : grid, object, none
function vt2string( vt )
{
switch ( vt )
{
case siInt4 : return "long";
case siDouble : return "double";
case siString : return "string";
case siBool : return "boolean";
case siUnknown : return "object";
case siWStr : return "wide string";
default : return vt;
}
} |