Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    How to press the "Apply" button in the DescriptionToolData?

    Cinema 4D SDK
    c++ python
    2
    2
    420
    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.
    • L
      LingZA
      last edited by

      How to press the "Apply" button in the DescriptionToolData?
      For c++ and python.
      APPLY.png
      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.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @LingZA
        last edited by

        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,
        Ferdinand

        Code:

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

        MAXON SDK Specialist
        developers.maxon.net

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