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

    First Time calling SetAction does show the Brush tool's AM

    Cinema 4D SDK
    r20 r21 c++
    3
    16
    1.6k
    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.
    • M
      m_adam
      last edited by m_adam

      Dev team confirmed this issue is resolved as a side effect of the document mode merging in R22 but they didn't remember exactly why it happened.
      I will try to take a look, but since there is an alternative (CallCommand, I know it is not optional because it screws the undo). I will put it as low prio on my side to look at and will be back (don't expect before the end of the week/start of next week).

      Cheers,
      Maxime.

      MAXON SDK Specialist

      Development Blog, MAXON Registered Developer

      C4DSC 1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS @m_adam
        last edited by C4DS

        @m_adam
        Sorry to say but CallCommand is not an option, as in my specific case the DescriptionTool I want to activate is a hidden plugin, and CallCommand cannot execute hidden ones.
        I understand the fact that CallCommand cannot call hidden plugins, and I don't assume this to be a bug. But if SetAction is an issue to use, and CallCommand doesn't execute as expected ... then what is one supposed to use?

        1 Reply Last reply Reply Quote 1
        • ferdinandF
          ferdinand
          last edited by ferdinand

          Hm,

          I never mentioned this, because I thought it is obvious, but since the thread has somehow come to a pass: Have you ever tried to exploit the fact that selecting two tools in row seems to solve the problem? I.e. first select some dummy tool and then the tool you actually want to select?

          Cheers,
          zipit

          MAXON SDK Specialist
          developers.maxon.net

          C4DSC 1 Reply Last reply Reply Quote 0
          • C4DSC
            C4DS @ferdinand
            last edited by C4DS

            @zipit
            I did try to activate a tool when initializing the plugin ... didn't make any difference.

            But to answer your actual question, I just tried the following:

            		doc->SetAction(ID_MODELING_ROTATE);
            		doc->SetAction(ID_MODELING_MOVE);
            		doc->SetAction(myPluginID);
            

            Sadly, no difference, the brush tool still gets shown into the AM.

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

              Hi,

              I am not sure if we are talking about the same thing, I meant (as extra lazy pseudo-code).

              edit: Jeah, just like that. But you could try to give Cinema some time to catch up and invoke an EventAdd() or doc->ExecutePasses between the tool activations.

              Cheers,
              zipit

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • M
                m_adam
                last edited by m_adam

                Hi @C4DS I tracked it down a bit.
                First of all this issue appears only if you are in BodyaPaint Layout mode.

                The main problem is that in R21 and previous versions, there is 2 tool logics (For BodyPaint and for Classic one) and more problematic, 2 different attribute manager, while in S22 there is only 1 attribute manager.

                The issue in R21 is that if there is no Mode selected, and you are in BP mode, SetAction assume that you want to define the BodyPaint Manager and command, so if you define previously the mode to a Polygon mode it will set is to the one you expect.

                doc->SetMode(Mpoints);
                doc->SetAction(ID_MODELING_ROTATE);
                SyncMessage(EVMSG_TOOLCHANGED, ID_MODELING_ROTATE);
                

                Defining the Mode to a modeling mode and make sure to also send EVMSG_TOOLCHANGED this way the internal state of command manager for BP will also be updated(otherwise you may see the command jump).

                Cheers,
                Maxime.

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                C4DSC 1 Reply Last reply Reply Quote 1
                • C4DSC
                  C4DS @m_adam
                  last edited by

                  @m_adam said in First Time calling SetAction does show the Brush tool's AM:

                  First of all this issue appears only if you are in BodyaPaint Layout mode.

                  Nope!
                  I am simply starting the application in its default state. The default startup layout, with the default move tool selected.

                  However, I agree that in the default state the Object Model mode is active So, if I indeed perform a mode change to set it to points (probably also edges or polygons will work) I can see the SetAction bringing the expected tool settings in the AM.
                  So, this might be a solution:

                  1. Switch mode to points/edge/polygon
                  2. SetAction
                  3. Switch to orginal mode
                  1 Reply Last reply Reply Quote 0
                  • C4DSC
                    C4DS
                    last edited by C4DS

                    This works:

                    		const Int32 currentMode = doc->GetMode();
                    // only change mode if current one is different from Mpoints, Medges, Mpolygons or Mpolyedgepoint
                    		doc->SetMode(Mpoints);
                    		doc->SetAction(MYTOOL_PLUGINID);
                    		GeSyncMessage(EVMSG_TOOLCHANGED, MYTOOL_PLUGINID);
                    		doc->SetMode(currentMode);
                    

                    Thanks for the hint.

                    EDIT:
                    FYI, note that I have only tested this solution on R20, not R21, but I assume it will behave identical.

                    1 Reply Last reply Reply Quote 0
                    • M
                      m_adam
                      last edited by

                      And I did test only on R21 so be sure to check again because I wasn't able to reproduce as you said with default layout in R21.

                      Cheers,
                      Maxime.

                      MAXON SDK Specialist

                      Development Blog, MAXON Registered Developer

                      C4DSC 1 Reply Last reply Reply Quote 0
                      • C4DSC
                        C4DS @m_adam
                        last edited by

                        @m_adam said in First Time calling SetAction does show the Brush tool's AM:

                        And I did test only on R21 so be sure to check again because I wasn't able to reproduce as you said with default layout in R21.

                        Cheers,
                        Maxime.

                        I am using R21.207 and with default layout see the brush tool in the AM (identical to what happens with R20.059). For safety, I have now tested your solution on R21 and works as expected.

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