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

    CallButton in C++

    Cinema 4D SDK
    c++ r19 r20
    2
    7
    1.5k
    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.
    • C4DSC
      C4DS
      last edited by

      The Python documentation mentions a c4d.CallButton, but I cannot find anything similar in the C++ documentation.

      What would be the C++ equivalent of the example below (provided in the Python documentation)?
      The CallCommand and FindPlugin I get, but how to perform the CallButton ?

      Or is this something which is only available to Python?

      import c4d
      
      c4d.CallCommand(c4d.ID_MODELING_TRANSFER_TOOL) # Set Transfer as current Tool
      
      tool = plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL) # Search Transfer Tool instance
      if tool is not None:
        c4d.CallButton(tool, c4d.MDATA_APPLY)
        c4d.EventAdd()
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi Daniel,

        You are right, this function is only available in Python.
        But in C++ take a look at the Attribute Manager Interaction Manual.

        Such button click is done by sending the following messages:

        	DescriptionCommand dc;
        	dc._descId = DescID(DescLevel(id, DTYPE_BUTTON, op->GetType()));
        
        	DescriptionCheckUpdate du;
        	du.doc = GetActiveDocument();
        	du.descid = &dc._descId;
        	du.drawflags = 0;
        
        	op->Message(MSG_DESCRIPTION_COMMAND, (void*)&dc);
        	op->Message(MSG_DESCRIPTION_CHECKUPDATE, (void*)&du);
        	op->Message(MSG_DESCRIPTION_USERINTERACTION_END);
        	op->Message(MSG_TOOL_RESTART);
        

        opis the host object of the button.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • C4DSC
          C4DS
          last edited by C4DS

          Thanks Maxime.
          However I seem to have trouble understanding what op should be in this case.
          What would be the host object of the button?

          In the Python documentation the transfer tool is used as example for the CallButton.
          How would I have to proceed to make this same example work in C++?

          I created a cube and a plane, selected the cube, activated the transfer tool and dragged the plane into the "Transfer to" field. Then tried the implementation you provided to get the "Apply" button pressed.
          Nothing happened.

          	BasePlugin* plug = FindPlugin(ID_MODELING_TRANSFER_TOOL, PLUGINTYPE_ANY);
          	if (plug)
          	{
          		const Int32 id = MDATA_APPLY;
          		BasePlugin* op = plug;
          
          		DescriptionCommand dc;
          		// R20
          		//dc._descId = DescID(DescLevel(id, DTYPE_BUTTON, op->GetType()));
          		// pre-R20
          		dc.id = DescID(DescLevel(id, DTYPE_BUTTON, op->GetType()));
          
          		DescriptionCheckUpdate du;
          		du.doc = GetActiveDocument();
          		// R20
          		//du.descid = &dc._descId;
          		// pre-R20
          		du.descid = &dc.id;
          		du.drawflags = 0;
          
          		op->Message(MSG_DESCRIPTION_COMMAND, (void*)&dc);
          		op->Message(MSG_DESCRIPTION_CHECKUPDATE, (void*)&du);
          		op->Message(MSG_DESCRIPTION_USERINTERACTION_END);
          		op->Message(MSG_TOOL_RESTART);
          		EventAdd();
          	}
          
          
          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by m_adam

            Hi @C4DS,

            In the case of a Tool, make sure it's currently active. For that please use CallCommand before your code. (Here is working nicely)

            Cheers,
            Maxime

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • C4DSC
              C4DS
              last edited by

              The tool was set active (manually and via CallCommand).
              But not working in R16, not working in R19.

              1 Reply Last reply Reply Quote 1
              • M
                m_adam
                last edited by m_adam

                Hi @C4DS,

                Indeed you were right, in R19 and bellow you have to explicitly pass PLUGINTYPE_TOOL and not PLUGINTYPE_ANY in the FindPlugin call to make it works.
                This is valid for Python as well.

                Cheers,
                Maxime.

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                1 Reply Last reply Reply Quote 2
                • C4DSC
                  C4DS
                  last edited by C4DS

                  Working as expected now ... didn't think of playing with the PLUGINTYPE_xxx
                  Thanks for details.

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