CustomProperty.AddParameterFromDef

Introduced

v5.0

Description

Creates a Parameter from a 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.

C# Syntax

Parameter CustomProperty.AddParameterFromDef( ParamDef in_pParamDef );

Scripting Syntax

oReturn = CustomProperty.AddParameterFromDef( ParamDef );

Return Value

The newly created Parameter object.

Parameters

Parameter Type Description
ParamDef ParamDef New parameter definition

Examples

JScript Example

/*
	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;	
	}	
}

See Also

XSIFactory.CreateParamDef XSIFactory.CreateParamDef2 XSIFactory.CreateFCurveParamDef XSIFactory.CreateGridParamDef