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

    Updating Tool Settings?

    Cinema 4D SDK
    2
    2
    456
    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.
    • dskeithD
      dskeith
      last edited by

      Hi,

      I'm currently porting a COFFEE script to Python and it seems that accessing/updating tool settings is much more complicated in Python than COFFEE.

      I initially tried something like:

      active_tool = doc.GetActiveToolData()
      active_tool[c4d.MDATA_AXIS_MODE] == 8  # Free Axis Mode
      c4d.EventAdd()
      

      But it had no effect. I eventually found my way to this post which led me to a solution like this:

      def tool():
          """Retrieves the currently active tool. Doing so allows you to modify tool settings
          unlike GetActiveToolData()"""
          
          active_tool_id = doc.GetAction()
          if not active_tool_id:
              return
          
          active_tool = c4d.plugins.FindPlugin(active_tool_id, c4d.PLUGINTYPE_TOOL)
          
          return active_tool
      
      def main():
          """Switch from Free Mode to Axis mode and vice/versa.
          """
          
          active_tool = tool()
          if active_tool is None:
              return
      
          active_tool[c4d.MDATA_AXIS_MODE] == 8  # Free Axis Mode
          c4d.EventAdd()
      

      Questions / Requests

      1. QUESTION: Is there a way of knowing when I should change settings with ActiveToolData() vs having to find an instance of the tool/plugin itself?
      2. IDEA: Please add a section to the docs on how to update tool settings.
      3. IDEA: Please add a helper function like tool() to the API for accessing the currently active tool, the present method is a bit convoluted for something people will want to do so frequently.

      Thank you,

      Donovan Keith

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        which tool do you actually want to configure?

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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