Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    ToolData::GetDDescription() redundant call, why?

    Cinema 4D SDK
    c++ r23
    3
    4
    813
    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.
    • WTools3DW
      WTools3D
      last edited by

      Hi,
      I have a questions about behavior of ToolData class member function GetDDescription().
      I can't find any example and I don't understand why Cinema is calling this function several times after each user event in GUI.

      Below is the code of overridden member function.
      I am filling description with controls every time now. (function LoadControls())

      Bool LwCadToolData::GetDDescription	(BaseDocument* doc, BaseContainer& data, Description* description, DESCFLAGS_DESC& flags)
      {
      	// validation
      	if (description == nullptr)		return false;
      		
      	ApplicationOutput("GetDDescription flags: @", flags);
      
      	// initialize controls	
      	LoadControls(C4dControls(description, description->GetSingleDescID()));
      
      	// controls loaded into tool description
      	flags |= DESCFLAGS_DESC::LOADED;
      
      	//---------------------
      	// base
      	return SUPER::GetDDescription(doc, data, description, flags);
      }
      

      Problem is that after each mouse event , this function is executed several times, always a different description pointer.
      Below is the list of calls after a single click.

      GetDDescription flags: NONE
      GetDDescription flags: NONE
      GetDDescription flags: NONE
      GetDDescription flags: NONE
      GetDDescription flags: RESOLVEMULTIPLEDATA|MAPTAGS
      GetDDescription flags: NONE

      Could you please give me a hint, how to optimize this properly?
      Optimal way is to fill description only once.
      Is it necessary fill it every time the GetDDescription() function is executed?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • P
        PluginStudent
        last edited by

        Cinema will call GetDDescription() whenever it feels like.

        But you can optimize by checking for GetSingleDescID(). You find a snippet here: https://developers.maxon.net/docs/cpp/2023_2/page_manual_description.html#page_manual_description_content_edit

        1 Reply Last reply Reply Quote 0
        • ferdinandF
          ferdinand
          last edited by

          Hi @WTools3D,

          thank you for reaching out to us. @PluginStudent already gave you the full answer. You cannot throttle the number of calls Cinema does make to your tag's GetDDescription, but you can limit modifications of the description with GetSingleDescID to only carry them out when they are being requested.

          Cheers,
          Ferdinand

          MAXON SDK Specialist
          developers.maxon.net

          1 Reply Last reply Reply Quote 0
          • WTools3DW
            WTools3D
            last edited by WTools3D

            Thank you guys for quick reply.
            But I was probably not clear enough with the question.

            I do understated the concept of setting panel description via GetDDescription() callback.
            I already did the checks for whether it is request for full description of just single id.
            As it is listed in the example below (it is member function of C4dControls class from previous snippet 😞

            void C4dControls::AddIntChoice(int id, int gid, const String& name, const BaseContainer& items)
            {	
            	const DescID cid = DescLevel(id, DTYPE_LONG, 0);
            	//---------------------------------------------------------------------
            	if (ex_descr && (!ex_singleid || cid.IsPartOf(*ex_singleid, nullptr)) )
            	{
            		BaseContainer bc = GetCustomDataTypeDefault(DTYPE_LONG);
            		//---------------------------------------------
            		bc.SetInt32	(DESC_CUSTOMGUI, ID_QUICKTABSRADIO_GADGET);
            		bc.SetString(DESC_NAME, name);
            		bc.SetInt32	(DESC_SCALEH, 1);
            		// animate OFF
            		bc.SetInt32	(DESC_ANIMATE, DESC_ANIMATE_OFF);
            		//---------------------------------------------
            		bc.SetContainer(DESC_CYCLE, items);
            		//---------------------------------------------
            		ex_descr->SetParameter(cid, bc, DescLevel(gid));
            	}	
            }
            

            But it is still calling to rewrite each control description several times after any event in GUI.
            What confuses me the most, is that each series of calls is with the different pointer to description (Description* description)
            For example there are five different pointers to description when ToolData::GetDDescription() is executed for the same event. (after mouse click into attribute manager)

            Is this the way how it really works?
            There are more versions of description for the same panel, and all of them have to be initialized repeatedly after each event?

            Thanks!
            Viktor

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