Access parameter failed
-
I recently recompiled my python deformer plugin using C ++, but encountered some trouble.
In function "Message()",I can access the parameters“SSURFACEDEFORMERC_DRIVER” and successfully get the name using GetName ()。
but in function "ModifyObject()", access same parameters“SSURFACEDEFORMERC_DRIVER” failed,return "nullptr".Thanks for any help!
this is part of code:
Bool SsurfaceDeformerc::Message(GeListNode* node, Int32 type, void* data) { if (type == MSG_DESCRIPTION_COMMAND) { DescriptionCommand* dc = static_cast<DescriptionCommand*>(data); BaseContainer* node_self = (static_cast<BaseObject*>(node))->GetDataInstance(); BaseDocument* doc = node->GetDocument(); if (dc == nullptr || node_self == nullptr) return true; if (dc->_descId[0].id == SSURFACEDEFORMERC_INITIALIZE) { //successfully access BaseObject* obj = static_cast<BaseObject*>(node_self->GetLink(SSURFACEDEFORMERC_DRIVER,doc,Obase)); ApplicationOutput(obj->GetName()); } return true; } // // Bool SsurfaceDeformerc::ModifyObject(BaseObject* op, BaseDocument* doc, BaseObject* mod, const Matrix& op_mg, const Matrix& mod_mg, Float lod, Int32 flags, BaseThread* thread) { if (!mod || !op || !doc || !thread) return false; BaseContainer* data = mod->GetDataInstance(); //failed access BaseObject* obj = static_cast<BaseObject*>(data->GetLink(SSURFACEDEFORMERC_DRIVER, doc, Obase)); if (!obj) { ApplicationOutput("No obj!"_s); return true; } return true }
-
Hello,
please have a look at the definition of the ModifyObject() method.
The first argument is the modifier object itself. The third argument is the object to modify.
For some reasons, you changed the names of the input parameters. But in C++, that won't matter. Only the type and the order of arguments is relevant.
So assuming that SSURFACEDEFORMERC_DRIVER is a parameter of the modifier object, you must access that modifier object. An in the context of ModifyObject(), that would be the first parameter.
best wishes,
Sebastian -
@s_bach Thanks, I ignored the parameter check and it works now!