NodeData based classic plugin classes can implement NodeData::Message() to receive various messages that are sent for several reasons. This page shows how to handle the most important messages.
NodeData::Message() is called by Cinema 4D to inform the plugin class about an event or to request some information from it. Additional data is handed over in form of a void pointer that has to be cast into the correct type depending on the message.
// This example shows a primitive implementation of Message().
With C4DAtom::MultiMessage() it is possible to send messages to the complete object hierarchy or branches (see also Heads and Branches). In this case it is possible to filter certain messages so they are not sent to the child elements of the given element.
Plugins use external assets typically by referencing the asset file in a Filename parameter. When the document is saved with "Save Project with Assets" or is rendered via Team Render these assets have to be collected. To collect these assets Cinema 4D sends these messages to all scene elements:
MSG_GETALLASSETS: This message is send to retrieve all assets used by an element.
MSG_MULTI_CLEARSUGGESTEDFOLDER: This message is sent so that the element replaces absolute asset paths with relative paths.
MSG_MULTI_MARKMATERIALS: When the given data is nullptr this is sent to scene elements to let them mark the materials they use (with BIT_MATMARK). Otherwise the message is sent to get material links translated, for example when a material is replaced. In this case the corresponding data is MarkMaterials. This is needed for example when an object that is using a material is copied.
MSG_RENAMETEXTURES: This message is sent to all scene elements when a bitmap image was renamed (e.g. by "Save Project" or by BodyPaint 3D) and all shaders etc. need to adjust the name. The message data is RenameTextureMessage.
An object or tag can include the ID_BASELIST_ICON_SETTINGS_GROUP parameter group. It is possible to add a custom color mode to that group and to define that custom color when reacting to MSG_GETCUSTOMICON.
// This example adds a new color mode to the object's "Icon Settings" in the Init() function.
// since we are going to use our custom MSG_GETCUSTOMICONS code, set this to true so parent object (e.g. BaseObject) will ignore MSG_GETCUSTOMICONS messages.
MessageDialog("You double-clicked on this object!"_s);
break;
}
Attribute Manager Interaction
Users edit scene elements and their parameters with the Attribute Manager. The Attribute Manager sends multiple messages to the edited object to inform about the interaction.
MSG_DESCRIPTION_CHECKDRAGANDDROP: Asks the element if a drag and drop onto for example a LINK description element or IN_EXCLUDE description element field should be accepted. Note that not all parameter types that might appear eligible do support this message, it is for example not supported by FieldList parameters. The corresponding data is DescriptionCheckDragAndDrop.
MSG_DESCRIPTION_INITUNDO: Allows elements to create undo actions for the following parameter changes in the Attribute Manager.
MSG_DESCRIPTION_TAKECHANGED: Sent to each overridden node when the user changes the current Take. Sent to both the node storing the data in the Take and the node releasing the data to the document. The corresponding data is DescriptionTakeChanged.
Creation
MSG_MENUPREPARE: Allows tags, objects, shaders etc. to do some setup work when called from the menu. The corresponding data is the current BaseDocument. Is called before the object is added to the document.
// This example adds a tag to the object when it is created from the menu.