Core Messages Manual

内容表

关于

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

注意
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:

注意
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).
警告
Do not use EventAdd() in a threaded context.
// This example shows how to create a new "Cube" object and how to insert it into the document.
BaseDocument * const document = GetActiveDocument (); if (document == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
BaseObject * const cubeObject = BaseObject::Alloc ( Ocube ); if (cubeObject == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); cubeObject-> SetName ( "This is a new object" _s); document-> InsertObject (cubeObject, nullptr , nullptr ); EventAdd ();

Catching Messages

Core messages are sent to update the GUI so it is possible to catch core messages in custom GUI elements:

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:

// This example MessageData::CoreMessage() catches EVMSG_CHANGE to detect any change. Bool CoreMessage( Int32 id , const BaseContainer & bc) { if ( id == EVMSG_CHANGE ) { if (g_printMessage) ApplicationOutput ( "Something was changed." ); } return true ; }

A core message can contain a BaseContainer argument. This container may store these values:

Message Types

These are Cinema 4D 's core messages:

// This example catches EVMSG_ASYNCEDITORMOVE in a GeDialog.

case EVMSG_ASYNCEDITORMOVE : { // check if this core message is new if (CheckCoreMessage(bc)) { const Int movement = ( Int )bc. GetVoid ( BFM_CORE_PAR1 ); switch (movement) { case MOVE_START : { ApplicationOutput ( "Start Movement" ); break ; } case MOVE_CONTINUE : { ApplicationOutput ( "Continue Movement" ); break ; } case MOVE_END : { ApplicationOutput ( "End Movement" ); break ; } } } break ; } // This example catches EVMSG_UPDATESCHEME in a GeDialog // to be informed when the scheme is changed.

case EVMSG_UPDATESCHEME : { // check if this core message is new if (CheckCoreMessage(bc)) { const Int scheme = ( Int )bc. GetVoid ( BFM_CORE_PAR1 ); switch (scheme) { case SCHEME_LIGHT : { ApplicationOutput ( "Light Scheme" ); break ; } case SCHEME_DARK : { ApplicationOutput ( "Dark Scheme" ); break ; } case SCHEME_OTHER : { ApplicationOutput ( "Other Scheme" ); break ; } } } break ; }

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.

// This example sends a custom core message. SpecialEventAdd (ID_CUSTOMEVENT, 123, 456);

// This example catches a custom core message.

case ID_CUSTOMEVENT: { const Int value1 = ( Int )bc. GetVoid ( BFM_CORE_PAR1 ); const Int value2 = ( Int )bc. GetVoid ( BFM_CORE_PAR2 ); const String value1String = String::IntToString (value1); const String value2String = String::IntToString (value2); ApplicationOutput ( "Value 1: " + value1String + ", value 2: " + value2String); break ; }

Other Functions

Other functions to send core messages are:

// This example forces an update of the attribute manager. SendCoreMessage ( COREMSG_CINEMA , BaseContainer ( COREMSG_CINEMA_FORCE_AM_UPDATE ));

延伸阅读

EVMSG_UPDATESCHEME
#define EVMSG_UPDATESCHEME
Scheme has been updated.
定义: ge_prepass.h:2573
GetActiveDocument
BaseDocument * GetActiveDocument(void)
COREMSG_CINEMA
#define COREMSG_CINEMA
Requests to Cinema 4D core.
定义: c4d_general.h:1497
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
Int
maxon::Int Int
定义: ge_sys_math.h:62
MOVE_END
#define MOVE_END
Move ended. par2 == ESC.
定义: ge_prepass.h:2569
BaseObject
定义: c4d_baseobject.h:224
BFM_CORE_PAR1
@ BFM_CORE_PAR1
ANY Parameter 1.
定义: gui.h:875
SpecialEventAdd
void SpecialEventAdd(Int32 messageid, UInt p1=0, UInt p2=0)
Ocube
#define Ocube
Cube.
定义: ge_prepass.h:1040
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
EVMSG_ASYNCEDITORMOVE
#define EVMSG_ASYNCEDITORMOVE
The user moved something in the editor window. Managers should update things like position fields.
定义: ge_prepass.h:2563
MOVE_CONTINUE
#define MOVE_CONTINUE
Move continued.
定义: ge_prepass.h:2568
BFM_CORE_PAR2
@ BFM_CORE_PAR2
ANY Parameter 2.
定义: gui.h:876
String
定义: c4d_string.h:38
String::IntToString
static String IntToString(Int32 v)
定义: c4d_string.h:495
SCHEME_OTHER
#define SCHEME_OTHER
Other.
定义: ge_prepass.h:2576
SendCoreMessage
GeData SendCoreMessage(Int32 coreid, const BaseContainer &msg, Int32 eventid=0)
BaseList2D::SetName
void SetName(const maxon::String &name)
定义: c4d_baselist.h:2324
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
BaseContainer::GetVoid
void * GetVoid(Int32 id, void *preset=nullptr) const
定义: c4d_basecontainer.h:343
EVMSG_CHANGE
#define EVMSG_CHANGE
Sent by EventAdd().
定义: ge_prepass.h:2530
BaseObject::Alloc
static BaseObject * Alloc(Int32 type)
MOVE_START
#define MOVE_START
Move started.
定义: ge_prepass.h:2567
EventAdd
void EventAdd(EVENT eventflag=EVENT::NONE)
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
SCHEME_LIGHT
#define SCHEME_LIGHT
Light.
定义: ge_prepass.h:2574
BaseDocument
定义: c4d_basedocument.h:490
COREMSG_CINEMA_FORCE_AM_UPDATE
#define COREMSG_CINEMA_FORCE_AM_UPDATE
Forces an Attribute Manager update.
定义: c4d_gui.h:88
BaseContainer
定义: c4d_basecontainer.h:46
SCHEME_DARK
#define SCHEME_DARK
Dark.
定义: ge_prepass.h:2575

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1