Getting and Setting Parameter Block Values
 
 
 

Parameter block values are get and set from an IParamBlock2 object using a ParamID that identifies the parameter value. This must be the same parameter identifier that is supplied as part of the parameter specification arguments.

Note: It is important not to confuse IParamBlock2::GetValue() and IParamBlock2::SetValue() with the parameter block 1 system for setting and retrieving values (IParamBlock::GetValue() and IParamBlock::SetValue()) which uses integer indexes instead of ParamID.

Getting Parameter Values

There are two sets of functions in class IParamBlock2 for retrieving values from the parameter block.

When accessing a value from the parameter block an Interval reference must be supplied. This method is frequently used by developers to 'whittle' down an interval. When a parameter of a parameter block is animated, for any given time there is a interval over which the parameter is constant. If the parameter is constantly changing the interval is instantaneous. If the parameter does not change for a certain period the interval will be longer. If the parameter never changes the interval will be FOREVER. By passing an interval to the GetValue() method you ask the parameter block to 'intersect' the interval passed in with the interval of the parameter. Intersecting two intervals means returning a new interval whose start value is the greater of the two, and whose end value is smaller of the two. In this way, the resulting interval represents a combined period of constancy for the two intervals.

This technique is used frequently to compute a validity interval for an object. The developer starts an interval off as FOREVER, then intersects this interval with each of its animated parameters (by calling GetValue()). GetValue() 'whittles' down the interval with each call. When all the parameters have been intersected the result is the overall validity interval of an object at a specific time. For more information see the section on Intervals.

The following code example is taken from the Bend modified example at maxsdk\howto\modifiers\bend\bendmod.cpp and demonstrates this technique:

Interval BendMod::GetValidity(TimeValue t)
{
  floatf = 0.0f;
  // Start our interval at forever...
  Interval valid = FOREVER;
  // Intersect each parameters interval to narrow it down.
  pblock2->GetValue(bend_angle,t,f,valid);
  pblock2->GetValue(bend_dir,t,f,valid);
  pblock2->GetValue(bend_from,t,f,valid);
  pblock2->GetValue(bend_to,t,f,valid);
  // Return the final validity interval.
  returnvalid;
}

The IParamBlock2::GetValue methods might be called in the following scenarios:

Setting Parameter Values

Functions for setting values in a parameter blocks.

Most of the time parameter values are modified automatically through the associated UI element on the roll-out window, or by an animation controller.

In some circumstances the parameter block value must be set manually. For example during interactive creation and modification of the object via the viewport. See CreateMouseCallback::proc() for an example of this.