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
    • Recent
    • Tags
    • Users
    • Login

    How to get/set tool data but not apply it?

    Scheduled Pinned Locked Moved PYTHON Development
    7 Posts 0 Posters 807 Views
    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.
    • H Offline
      Helper
      last edited by

      On 25/06/2015 at 22:45, xxxxxxxx wrote:

      How is it that you get/set the current tool's(or any tool's) data?

      For instance, if I wanted to change say the modeling axis in the live selection or move tools how would I do it?

      Or like if you wanted to for instance set the extrude tool's offset to 75, but not APPLY the command, how do you go about setting that?

      I can do Get/SetAction, and GetActiveToolData, but you cannot seem to SetActiveToolData.

      I'm sure it's something simple, but it's late and I'm missing something.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 28/06/2015 at 16:58, xxxxxxxx wrote:

        Is this not at all possible?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 29/06/2015 at 09:13, xxxxxxxx wrote:

          Hi,

          doc.GetActiveToolData() returns the container instance for a tool. Its values can then be modified directly and the changes will be reflected automatically after calling c4d.EventAdd(). This explains why there's no doc.SetActiveToolData().

          Here's a simple script to do this:

          import c4d
            
          data = doc.GetActiveToolData()
          action = doc.GetAction()
          if data is not None and action==c4d.ID_MODELING_EXTRUDE_TOOL:
              data[c4d.MDATA_EXTRUDE_OFFSET]=75.0
              c4d.EventAdd()
          

          EDIT: Updated script.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 30/06/2015 at 23:12, xxxxxxxx wrote:

            Thanks for the script Yannick.

            However I still seem to be having troubles.

            Using this code doesn't work, and doesn't error either.

            data = doc.GetActiveToolData()
              action = doc.GetAction()
              if data is not None and action==c4d.ID_MODELING_MOVE:
                  data[c4d.MDATA_AXIS_ROT]=2
                  data[c4d.MDATA_AXIS_NORMAL_PSR]=True
                  c4d.EventAdd()

            Any ideas what is going on? I am trying to be able to toggle the settings of the move tool but I can't seem to access it.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 01/07/2015 at 01:30, xxxxxxxx wrote:

              Hi,

              To change the parameters of the Move/Scale/Rotate tools we have to retrieve the tool instance:

              import c4d
              from c4d import plugins
                
              tool = plugins.FindPlugin(c4d.ID_MODELING_MOVE, c4d.PLUGINTYPE_TOOL)
              if tool is not None:
                  tool[c4d.MDATA_AXIS_ROT] = 5
                  tool[c4d.MDATA_AXIS_NORMAL_PSR] = True
                  c4d.EventAdd()
              
              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 01/07/2015 at 23:34, xxxxxxxx wrote:

                Thanks Yannick, That seems to work.

                But one question, what dictates when one must use FindPlugin vs GetActiveToolData? Is there some kind of difference there that one must know of? When should one be used vs the other?

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 02/07/2015 at 01:35, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  But one question, what dictates when one must use FindPlugin vs GetActiveToolData? Is there some kind of difference there that one must know of? When should one be used vs the other?

                  In fact BaseDocument.GetActiveToolData() calls GetToolData(doc, doc->GetAction()). And GetToolData() calls FindPlugin(pluginid, PLUGINTYPE_TOOL). So there should not be no difference between FindPlugin() and GetActiveToolData().
                  But there seems to have an issue with the Move/Rotate/Scale tools data containers returned by GetActiveToolData().

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