Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

call a mouse click command in viewport

 Post Reply Post Reply
Author
Message
MohamedSakr View Drop Down
Member
Member
Avatar

Joined: 2012 Sep 17
Location: Egypt
Online Status: Offline
Posts: 577
Post Options Post Options   Quote MohamedSakr Quote  Post ReplyReply Direct Link To This Post Topic: call a mouse click command in viewport
    Posted: 2018 Apr 30 at 6:23am

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).

cheers,
Mohamed Sakr
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1785
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 May 03 at 2:10am
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).

Cheers,
Andreas
SDK Support Engineer
Back to Top
MohamedSakr View Drop Down
Member
Member
Avatar

Joined: 2012 Sep 17
Location: Egypt
Online Status: Offline
Posts: 577
Post Options Post Options   Quote MohamedSakr Quote  Post ReplyReply Direct Link To This Post Posted: 2018 May 10 at 3:58pm
thanks, pickobject was what I needed.
cheers,
Mohamed Sakr
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.