Requirements to access external parameter blocks?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Now that I am able to successfully create my object plugin from my utility plugin, I want to be able to control the object's parameters from the utility. utiltest.cpp contains an example in which a created cylinder's height and radius are accessed using the following:
Object *obj = (Object*)ip->CreateInstance(GEOMOBJECT_CLASS_ID, Class_ID(CYLINDER_CLASS_ID,0)); assert(obj); IParamArray *iCylParams = obj->GetParamBlock(); assert(iCylParams);
followed by a series of parameter statements in the format of:
int param = obj->GetParamBlockIndex(INDEX_INTEGER); assert(param>=0); iCylParams->SetValue(param, TimeValue(0), value);
to set the initial values.
Using this code as-is, I can make my own utility create a cylinder like the sample file. However, when I try to substitute my own plugin object, I get the error:
In which Line: ### refers to the line of the statement
My object base class includes the methods:
int GetParamBlockIndex(int id) { return id; }
IParamBlock2 *GetParamBlock(int i) { return pblock; }
IParamBlock2 *GetParamBlockByID (BlockID id) { return pblock->ID() == id ? pblock : NULL; }
and the source file contains the following:
enum { obj_params };
enum { obj_size };
static ParamBlockDesc2 obj_pblock (
obj_params, _T("ObjectParameters"), 0, &ObjDesc, P_AUTO_CONSTRUCT + P_AUTO_UI, PBLOCK_REF,
IDD_PANEL, IDS_PARAMS, 0, 0, NULL,
obj_size, _T("size"), TYPE_WORLD, P_ANIMATABLE, IDS_SIZE,
p_default, 0.0f, p_ms_default, 10.0f,
p_range, 0.0f, float(1.0E30),
p_ui, TYPE_SPINNER, EDITTYPE_UNIVERSE, IDC_SIZE_EDIT, IDC_SIZE_SPIN, SPIN_AUTOSCALE, p_accessor, &ObjDesc, end,
end
);
The object in question is of the HelperObject type, and its parameters work internally (it can be resized using a spinner).
What is most likely causing the Assertion Failed error? Is there something I need to add or change in my object source code to make it properly accessible by my utility? Or is there something that I need to add to my utility plugin to allow it to access my object?