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

    call a mouse click command in viewport

    SDK Help
    0
    3
    1.0k
    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
      Helper
      last edited by

      On 30/04/2018 at 06:23, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   16+ 
      Platform:      
      Language(s) :     C++  ;

      ---------
      what I want to do:
      pick camera focus (the pick icon from the camera object, then click in the viewport to pick the focus)

      I can already call the command for that camera button

        
      doc->SetActiveObject(cam);
      DescriptionCommand dcommand;
      dcommand.id = CAMERAOBJECT_TARGETDISTANCE_PICK;
      cam->Message(MSG_DESCRIPTION_COMMAND, &dcommand);
      EventAdd();
      

      now what I want is call a click in the viewport (I already have the BaseDraw*, x and y screen coordinates).

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

        On 03/05/2018 at 02:10, xxxxxxxx wrote:

        Hello Mohamed,

        it is not possible to "inject" mouse clicks via the API.

        Instead of virtually trying to imitate user behavior, rather do it the other way round.
        You already know the coordinates and do have the BaseDraw. With this you should be able to get the needed distance in various ways and could then simply set the parameter for the camera object.

        Internally the "Pick Focus" button of the camera object uses the ViewportSelect class. See examples of its use in sculpting and pickobject examples in cinema4dsdk.

        Another option may be the use of a pick session, see StartPickSession(), StopPickSession() and GetPickSession() as well as the PickSessionDataStruct (see some snippets of its usage here).

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

          On 10/05/2018 at 15:58, xxxxxxxx wrote:

          thanks, pickobject was what I needed.

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