How to press the "Apply" button in the DescriptionToolData?
-
How to press the "Apply" button in the DescriptionToolData?
For c++ and python.
For python:import c4d def main() -> None: c4d.CallCommand(450000263) # C++ SDK - Pick Object Tool tool = c4d.plugins.FindPlugin(450000263, c4d.PLUGINTYPE_TOOL) tool[c4d.MDATA_INTERACTIVE] = True c4d.EventAdd() if tool is not None: c4d.CallButton(tool, c4d.MDATA_APPLY) c4d.CallButton(tool, c4d.MDATA_NEWTRANSFORM) c4d.EventAdd() print("execute") if __name__ == '__main__': main()
The python code can excute the settings of the tool. But the "Apply" button isn't pressed and disenabled like the manual pressing action to get the realtime update.
-
Hello @LingZA,
Thank you for reaching out to us. Thank you for posting your solution, much appreciated! I have provided below a variant of your example which without having the C++ Example Pick Object Tool installed.
In case someone is wondering how to find out such a thing, you would have to look into the description of a tool, e.g. the extrude tool ...
toolextrude.res
:CONTAINER xbeveltool { NAME xbeveltool; GROUP MDATA_BEVEL_GROUP_OPTION { DEFAULT 1; LONG MDATA_BEVEL_MASTER_MODE // ... } INCLUDE ToolBase; // Includes the gadgets that are common to all description tools. }
to find out that they all include all
ToolBase
which then looks like this:toolbase.res
:CONTAINER ToolBase { NAME ToolBase; GROUP MDATA_MAINGROUP { DEFAULT 1; } GROUP MDATA_COMMANDGROUP { DEFAULT 1; GROUP { // SEPARATOR { LINE; } BOOL MDATA_INTERACTIVE { } SEPARATOR { } GROUP { COLUMNS 2; DEFAULT 1; BUTTON MDATA_APPLY { FIT_H; } BUTTON MDATA_NEWTRANSFORM { FIT_H; } } } } SUBCONTAINER ID_SNAPSETTINGS { } }
Cheers,
FerdinandCode:
"""Actives and runs the extrude tool. """ import c4d ID_EXTRUDE_TOOL: int = 1011183 def main() -> None: c4d.CallCommand(ID_EXTRUDE_TOOL) tool = c4d.plugins.FindPlugin(ID_EXTRUDE_TOOL, c4d.PLUGINTYPE_TOOL) tool[c4d.MDATA_INTERACTIVE] = True c4d.EventAdd() if tool is not None: c4d.CallButton(tool, c4d.MDATA_APPLY) c4d.CallButton(tool, c4d.MDATA_NEWTRANSFORM) c4d.EventAdd() if __name__ == '__main__': main()