Solved CallButton in C++

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()

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.

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();
	}

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

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

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.

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