ToolData detect change of active object [SOLVED]



  • On 02/01/2017 at 01:47, xxxxxxxx wrote:

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

    ---------
    I am wondering how to detect when the user selects a different object, from within a ToolData plugin.
    Making another object the active one results in an EVMSG_CHANGE being sent, but this is a coremessage and thus not captured by the ToolData::Message method.

    I know I could store the current active object (via its GUID, or other value) as a member in the instance of the ToolData class and keep checking until the current active object is different from the stored value. But this checking is only triggered when MouseInput, GetCursorInfo, or other methods are called. Methods which only get called when the mouse cursor is over the viewport.
    While I would like to prepare some data as soon as the user selects another object (in the object manager), and not wait until the mouse cursor is moved into the viewport in order to detect the change.

    A workaround would be to perform the checking of the EVMSG_CHANGE in a MessageData plugin ... but how to trigger the ToolData plugin from the MessageData one? Sending a SpecialEventAdd again is only captured as a coremessage.

    I've looked through the SDK, done some searches in this forum. But not knowing what keywords to search for doesn't make it easier to find a solution.



  • On 02/01/2017 at 02:58, xxxxxxxx wrote:

    OK, got the workaround working. Sending a message to the ToolData plugin is as easy as

    BasePlugin* plugin = FindPlugin( <pluginID>, <plugintype> )
    if (plugin) plugin->Message( <whatever> );

    Took me a few days before posting the question, and of course, once posted I found my own answer.


Log in to reply