Get active tool

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/04/2009 at 07:27, xxxxxxxx wrote:

User Information:
Cinema 4D Version:    
Platform:      
Language(s) :     C++  ;

---------
Hi,

I would like to get the current active tool but can't find any method. Well, I found the settings container but I would like to get the tool as BaseList2D element.

Any suggestions?

Thanks and bye.
Shawni

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/04/2009 at 07:31, xxxxxxxx wrote:

BaseDocument::GetAction()

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/04/2009 at 08:28, xxxxxxxx wrote:

thanks, works fine, but the stuff I want to do, does not work.

I just want to call a button.
Via BaseDocument::GetAction() and FindPlugin(..., 0) I get the plugin instance.

object = FindPlugin(...)

DescriptionCommand dc;
dc.id = DescID(id);
    Py_RETURN_BOOL(object->Message(MSG_DESCRIPTION_COMMAND,&dc;));

It returns True, but the button was not really pressed. Any suggestion what might be wrong?

Thanks.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/04/2009 at 08:57, xxxxxxxx wrote:

To set the current tool, use BaseDocument::SetAction(). That enables the tool by its ID (should work with plugin tools as well - best to test). You can't 'do' anything with the tool though. Tools aren't commands, they are tools and require user interaction thereafter.

Not sure what you are after. 🙂

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/04/2009 at 09:15, xxxxxxxx wrote:

I just want to call a button (see CloneTool ->"Apply" or ClothTag->"Calculate"). I know that a tool is not just a button, but a tool might contain a button.

The new Coffee SDK contains CallButton(...) which does exactly what I want to do, just in C++ 🙂

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 07/04/2009 at 09:42, xxxxxxxx wrote:

You might need to do it this way:

object = FindPlugin(...);
DescriptionCommand descCMD;
descCMD.id = DescID(DescLevel(id,DTYPE_BUTTON,0));
Py_RETURN_BOOL(object->Message(MSG_DESCRIPTION_COMMAND, &descCMD;));

I'm just not sure if all of the possibilities in the FindPlugin() part will result in valid 'plugin' ids that result in a BasePlugin* being returned.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/04/2009 at 03:44, xxxxxxxx wrote:

hi, doesn't work either. Hmm..

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/04/2009 at 04:24, xxxxxxxx wrote:

This seems to work. I used the CreatePolygon tool to test.

> \> Bool MenuTest::Execute(BaseDocument \*doc) \> { \>      LONG tool_id = doc->GetAction(); \> \>      BasePlugin \*tool = NULL; \>      tool = FindPlugin(tool_id, C4DPL_TOOL); \> \>      if(!tool) return FALSE; \> \>      DescriptionCommand dc; \>      dc.id = DescID(MDATA_CREATEPOLYGON_BUTTON); \>      tool->Message(MSG_DESCRIPTION_COMMAND, &dc;); \> \>      EventAdd(); \> \>      return TRUE; \> } \>

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/04/2009 at 06:40, xxxxxxxx wrote:

This works fine here, too. In my case its the Apply Button of the Clone Tool. But I will check that again and I will tell you what I did wrong.

cheers,
Shawni

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 13/04/2009 at 08:49, xxxxxxxx wrote:

Hi, I guess I've the correct IDs.

> \>      CallCommand(450000042); \>      LONG tool_id = doc->GetAction(); // select the Clone tool \> \>      BasePlugin \*tool = NULL; \>      tool = FindPlugin(tool_id, C4DPL_TOOL); \> \>      if(!tool) return FALSE; \> \>      DescriptionCommand dc; \>      dc.id = DescID(MDATA_APPLY); \>      tool->Message(MSG_DESCRIPTION_COMMAND, &dc;); \> \>      EventAdd(); \>

Any suggestions? Thanks.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/04/2009 at 03:00, xxxxxxxx wrote:

It seems that the DescriptionToolData Apply, New Transform and Reset Values buttons are triggered differently. I have asked the developers how the CallButton() command is working internally.

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/04/2009 at 04:08, xxxxxxxx wrote:

heyho, any news?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2009 at 01:05, xxxxxxxx wrote:

Quote: Originally posted by Shawni on 20 April 2009
>
> * * *
>
> heyho, any news?
>
>
> * * *

Sorry, not yet.

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/04/2009 at 01:20, xxxxxxxx wrote:

Hope it's not too late, anyways here is the working code.

> \> Bool MenuTest::Execute(BaseDocument \*doc) \> { \>      LONG tool_id = doc->GetAction(); \> \>      BasePlugin \*tool = NULL; \>      tool = FindPlugin(tool_id, C4DPL_TOOL); \>      if (!tool) return FALSE; \> \>      BaseContainer msg(BFM_ACTION); \>      msg.SetLong(BFM_ACTION_ID, 1440); \>      msg.SetLong(BFM_ACTION_VALUE, TRUE); \> \>      DescriptionCommand dc; \>      dc.id = DescID(DescLevel(MDATA_APPLY, DTYPE_BUTTON, tool->GetType())); \> \>      DescriptionCheckUpdate du; \>      du.doc = doc; \>      du.descid = &dc.id; \>      du.drawflags = 0; \> \>      tool->Message(MSG_DESCRIPTION_COMMAND, (void\* )&dc;); \>      tool->Message(MSG_DESCRIPTION_CHECKUPDATE, (void\* )&du;); \>      tool->Message(MSG_DESCRIPTION_USERINTERACTION_END); \>      tool->Message(MSG_TOOL_RESTART); \> \>      EventAdd(); \> \>      return TRUE; \> } \>

As you can see you have too send some more messages to make it work. This should work with every button. It's almost identically with internal code for CallButton().

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/04/2009 at 02:10, xxxxxxxx wrote:

hey Matthias, wow, thank you! Works fine.