XSIFactory.CreateParamDef2
 
 
 

XSIFactory.CreateParamDef2

Introduced

v4.0

Description

Creates a new custom parameter definition (ParamDef object).

ParamDef objects contain the definition of a parameter from which you can create new parameters on the fly for one or more property sets or operators. For example, you may want to use a double with the same min/max range and use it on multiple property sets or you may simply want a quick way to add parameters to a runtime scripted operator via scripting. You can create New ParamDef objects from the XSIFactory object.

Note: If you need to specify capabilities, classification, or suggested minimum and maximum values, use XSIFactory.CreateParamDef instead.

C# Syntax

ParamDef XSIFactory.CreateParamDef2( String in_ScriptName, siVariantType in_Type, Object in_default, Object in_Min, Object in_Max );

Scripting Syntax

oReturn = XSIFactory.CreateParamDef2( ScriptName, Type, [DefaultValue], [Min], [Max] );

Return Value

The newly created ParamDef object.

Parameters

Parameter Type Description
ScriptName String This argument specifies the ScriptName of a parameter (see Parameter.ScriptName). If the short name or long name arguments are not specified then this name is also used as the short name and description.
Type siVariantType Type of the custom parameter. The recommended types are: siString, siBool, siInt4, siUByte, and siDouble. The supported types are: siString, siBool, siDouble, siFloat, siInt4, siInt2, siUInt4, siUInt2, siByte, siUByte (see Parameter.ValueType).
DefaultValue Variant Default value of the custom parameter. A default value for numerical values (including boolean) is 0; the string default is "" (see Parameter.Default).
Min Variant Minimum value of the custom parameter. The types siString and siBool do not require a Min value. For all other numerical types the default is the minimum value possible for the type. For example, all unsigned values have a minimum value of 0 (see Parameter.Min).
Max Variant Maximum value of the custom parameter. The types siString and siBool do not require a Max value. For all other numerical types the default is the minimum value possible for the type. For example, the maximum value for siUByte is 255 (see Parameter.Max)

Examples

JScript Example

// This example illustrates how to add parameters to a custom operator
NewScene( null, false )
var null1 = GetPrim("null");
// Create the operator
var sop = XSIFactory.CreateScriptedOp( "MySOP", MySOP_Update.toString(), "JScript" );
// Add the ports
sop.AddOutputPort( null1.posx );
// Add the parameters
var param1 = sop.AddParameter( XSIFactory.CreateParamDef2("text", siString, "hello") );
var param2 = sop.AddParameter( XSIFactory.CreateParamDef2("bool", siBool, true) );
var param3 = sop.AddParameter( XSIFactory.CreateParamDef2("int", siInt4, 10, 0, 100) );
var param4 = sop.AddParameter( XSIFactory.CreateParamDef2("dbl", siDouble, 0.5, 0.0, 1.0) );
// List operator's parameters
var eParams = new Enumerator( sop.parameters );
for ( ; !eParams.atEnd(); eParams.moveNext() )
{
        var param = eParams.item();
         Application.LogMessage( param.Name + " = " + param.Value );
}
// Connect the operator
sop.Connect();
// Operator's update function
function MySOP_Update( ctx, out )
{
        out.Value = ctx.CurrentFrame;
}

See Also

CustomOperator.AddParameter, ParamDef