Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Access parameter failed

    Cinema 4D SDK
    c++ r21
    2
    3
    354
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • chuanzhenC
      chuanzhen
      last edited by

      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
      }
      

      相信我,可以的!

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by s_bach

        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

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        chuanzhenC 1 Reply Last reply Reply Quote 0
        • chuanzhenC
          chuanzhen @s_bach
          last edited by

          @s_bach Thanks, I ignored the parameter check and it works now!

          相信我,可以的!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post