轉自:3ds max skd 9 :creating a Paramter Block .(稍後翻譯)
Parameter Block Creation Methods
There are two methods for creating a parameter block.
The First method is a global function defined in iparamb2.h:
IParamBlock2 *CreateParameterBlock2(ParamBlockDesc2 *pdesc, ReferenceMaker* iowner);
The second method is:
void ClassDesc2::MakeAutoParamBlocks(ReferenceMaker* owner)
which is a member function of a class descriptor object (i.e. class ClassDesc2).
Of the two methods, plugin developers should almost without exception use the MakeAutoParamBlocks function. In fact MakeAutoParamBlocks internally calles the CreateParameterBlock2 function. It is standard practice to call the MakeAutoParamBlocks when the plugin object gets created - usually this is done in the plugin's constructor function. i.e.
Widget::Widget()
{
WidgetDesc.MakeAutoParamBlocks(this);
}
These functions shown above are not called by the plugin developer, but are called internally by Max. The plugin developer simply has to implement them properly. If the parameter block is created using the MakeAutoParamBlocks methods, then certain arguments must be set in describing the parameter block. These arguments are described below.
Number of parameter blocks per plugin
A plugin can have any number of parameter blocks. All the parameter blocks for that plugin should be associated with one class descriptor for each plugin. This is accomplished by passing the same class descriptor object address to each Parameter Block Descriptor constructor. For example:
static ParamBlockDesc2 widget_param_blk (
//...
, &WidgetDesc,
//...
);
static ParamBlockDesc2 widget_param_blk_extra (
//...
, &WidgetDesc,
//...
);
When Max creates the parameter block by calling MakeAutoParamBlocks it automaticly loop through all the parameter block descriptors that have been registered with the class descriptor.