Buttons: Apply, NewTransform,Reset

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

On 09/04/2012 at 07:47, xxxxxxxx wrote:

Maxon,
Please provide me(us) the python code to execute these buttons.
They are executed differently from the other buttons.

Here is a C++ example of executing the Apply button on the TransformTool:

    CallCommand(200000069);                                    //Launch the Transfer Tool  
  LONG tool_id = doc->GetAction();                           //Get the active tool  
  BasePlugin *tool = FindPlugin(tool_id, PLUGINTYPE_TOOL);   //Get the tools id  
  if (!tool) return FALSE;   
  
/////////// This section of code is used to execute the Apply button ///////////////      
  BaseContainer bc(BFM_ACTION);                     //Create a container with an action id  
  bc.SetLong(BFM_ACTION_ID, MDATA_TRANSFER_);       //Executes the transfer tool's apply button  
  bc.SetLong(BFM_ACTION_VALUE, TRUE);               //Not sure if this is actually needed or not  
  
  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);  
  //////// End button code ///////////////////

Please provide me(us) with the python code version of this.

Thanks,
-ScottA

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

On 10/04/2012 at 03:23, xxxxxxxx wrote:

Hi,

The Python code is:

import c4d
from c4d import plugins
  
  
def main() :
    c4d.CallCommand(c4d.ID_MODELING_TRANSFER_TOOL)
    
    tool = plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
    if tool is not None:
        c4d.CallButton(tool, c4d.MDATA_APPLY)
        c4d.EventAdd()
  
if __name__=='__main__':
    main()

EDIT: I finally found how to make it work; I just missed c4d.EventAdd(). It's also missing in your C++ code.

And this code does nothing and isn't necessary:

Originally posted by xxxxxxxx

/////////// This section of code is used to execute the Apply button ///////////////    
BaseContainer bc(BFM_ACTION);                 //Create a container with an action id
bc.SetLong(BFM_ACTION_ID, MDATA_TRANSFER_);   //Executes the transfer tool's apply button
bc.SetLong(BFM_ACTION_VALUE, TRUE);           //Not sure if this is actually needed or not

MDATA_TRANSFER_ marks the end of MDATA_TRANSFER's container entry enumeration; it's not a valid ID.

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

On 10/04/2012 at 08:07, xxxxxxxx wrote:

Thank You sir.:beer:

Please, please, please always include the button code to execute tools in the docs in the future.
Every time they add a new tool. I have to contact support to ask how to execute them.
I shouldn't have to bother you guys with such trivial questions.

BTW: This code also does not work in R12.

Keep up the good work Yannick,
-ScottA