About
Core messages are sent around Cinema 4D to inform various parts of the application about events and changes. This is happens so different parts of the interface can update their status (e.g. Attribute Manager, Viewport, etc.).
- Note
- Other important message types are messages sent to C4DAtom based elements (see C4DAtom Manual and NodeData::Message() Manual) and GUI messages (GUI and Interaction Messages Manual).
EventAdd
When the active document is changed by some operation one must inform Cinema 4D about this, so Cinema 4D can update the GUI.
Valid flags are:
- Note
- This is only needed when the active document is changed. It is not needed when a virtual or internal document is edited or when objects are handled that are not part of a document.
-
Events are not sent if no GUI exists (if CINEMAINFO::FORBID_GUI is true).
- Warning
- Do not use EventAdd() in a threaded context.
if (document == nullptr)
BaseObject*
const cubeObject = BaseObject::Alloc(
Ocube);
if (cubeObject == nullptr)
cubeObject->SetName("This is a new object"_s);
document->InsertObject(cubeObject, nullptr, nullptr);
#define Ocube
Cube.
Definition: ge_prepass.h:1118
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
BaseDocument * GetActiveDocument()
void EventAdd(EVENT eventflag=EVENT::NONE)
Catching Messages
Core messages are sent to update the GUI so it is possible to catch core messages in custom GUI elements:
- GeDialog::CoreMessage(): Receives core messages in a custom GeDialog.
- GeUserArea::CoreMessage(): Receives core messages in a custom GeUserArea.
When EVMSG_CHANGE is received, GeDialog based custom panels typically re-initialize their values by calling GeDialog::InitValues().
It is also possible to catch core messages with a MessageData plugin:
- MessageData::CoreMessage(): Receives core messages in a custom MessageData plugin.
Bool CoreMessage(
Int32 id,
const BaseContainer& bc)
{
{
if (g_printMessage)
}
return true;
}
#define EVMSG_CHANGE
Sent by EventAdd().
Definition: ge_prepass.h:2768
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
maxon::Bool Bool
Definition: ge_sys_math.h:46
maxon::Int32 Int32
Definition: ge_sys_math.h:51
A core message can contain a BaseContainer argument. This container may store these values:
- ::BFM_CORE_ID: The core message ID.
- ::BFM_CORE_UNIQUEID: Time stamp.
- ::BFM_CORE_PAR1: Parameter 1.
- ::BFM_CORE_PAR2: Parameter 2.
- ::BFM_CORE_SPECIALCOREID: Special manager ID for synchronization messages.
Message Types
These are Cinema 4D's core messages:
{
if (CheckCoreMessage(bc))
{
switch (movement)
{
}
}
break;
}
@ BFM_CORE_PAR1
ANY Parameter 1.
Definition: gui.h:903
#define MOVE_END
Move ended. par2 == ESC.
Definition: ge_prepass.h:2807
#define EVMSG_ASYNCEDITORMOVE
The user moved something in the editor window. Managers should update things like position fields.
Definition: ge_prepass.h:2801
#define MOVE_CONTINUE
Move continued.
Definition: ge_prepass.h:2806
#define MOVE_START
Move started.
Definition: ge_prepass.h:2805
maxon::Int Int
Definition: ge_sys_math.h:55
{
if (CheckCoreMessage(bc))
{
switch (scheme)
{
}
}
break;
}
#define EVMSG_UPDATESCHEME
Scheme has been updated.
Definition: ge_prepass.h:2811
#define SCHEME_DARK
Dark.
Definition: ge_prepass.h:2813
#define SCHEME_OTHER
Other.
Definition: ge_prepass.h:2814
Custom Messages
It is possible to send custom, asynchronous core messages. This can be used to send a message from a custom thread into the main thread.
void SpecialEventAdd(Int32 messageid, UInt p1=0, UInt p2=0)
case ID_CUSTOMEVENT:
{
const String value1String = String::IntToString(value1);
const String value2String = String::IntToString(value2);
break;
}
@ BFM_CORE_PAR2
ANY Parameter 2.
Definition: gui.h:904
Other Functions
Other functions to send core messages are:
#define COREMSG_CINEMA
Requests to Cinema 4D core.
Definition: c4d_general.h:1569
#define COREMSG_CINEMA_FORCE_AM_UPDATE
Forces an Attribute Manager update.
Definition: c4d_gui.h:95
GeData SendCoreMessage(Int32 coreid, const BaseContainer &msg, Int32 eventid=0)
Further Reading