Send message to tooldata

  • How can I send data from a command plugin dialog to a tooldata plugin?
    I tried following in the command plugin

                self.mode = id
                #c4d.SpecialEventAdd(PLUGIN_ID2, p1=id, p2=id)  
                msg = c4d.BaseContainer()
                msg[1] = id
                self.CoreMessage(c4d.EVMSG_TOOLCHANGED, msg)

    But nothing is received in the tooldata plugin.

        def Message(self, node, type, data):
            if type==c4d.EVMSG_TOOLCHANGED:
                print "EVMSG_TOOLCHANGED"
                if data['id'][0].id==PLUGIN_ID2:
                    print "Pushed button with the ID", PLUGIN_ID2
                    return True
        def CoreMessage(self, id, msg):
            if id == PLUGIN_ID2:
               print "Message received."

  • If I remember correctly we did discuss the other way (from CommandData to ToolData) quite a while ago (see But I guess using this same technique could still be applicable to your current request.

    Most important is to understand that a CoreMessage is not captured by a ToolData. This type of message can only be captured by a MessageData plugin, where you then could "translate" it into a message that actually is sent to the ToolData.

    What I have been successful in using is, performing following from the "transmitter":

    BasePlugin* tool = FindPlugin(TOOL_PLUGIN_ID, PLUGINTYPE::TOOL);
    if (tool)

    Where TOOL_PLUGIN_ID is the plugin ID of the ToolData, and TOOL_MSG_PREPAREDATA is a custom defined message, using a unique plugin ID.

    And then using following in the "receiver" ToolData:

    Bool MyToolData::Message(BaseDocument *doc, BaseContainer &data, Int32 type, void *t_data)
    	if (type == TOOL_MSG_PREPAREDATA)
    	return DescriptionToolData::Message(doc, data, type, t_data);

  • Furthermore, I am not sure you can simply sent out a EVMSG_TOOLCHANGED.
    Why would you do so?
    Best is to actually perform a change of tool (by doing a doc->SetAction(...)), which will automatically sent out this message. But of course the message being a CoreMessage it can only be captured by a MessageData plugin. Again, you could provide this detection and "translate" that captured EVMSG_TOOLCHANGED into a "tool->Message(custom_msg_id_toolchanged)", which you would then listen to in your ToolData::Message()

  • @C4DS said in Send message to tooldata:


    Your first answer works great! Thank you.

Log in to reply