Hi there,
I'm trying to find a way to detect in a Python plugin a document change when I'm switching between different document in C4D. The switch do not concern file open, then close, and open an other document, but really having 2 or 3 different scenes opened at the same time and switching from one to an another.
I went through the different post here, but I didn't found anything relevant, only few tracks, and also some C++ examples but they have some functions that are not existing in Python (ie GeDialog::CheckCoreMessage()
). The best example I found is in C++ there : https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_manual_gedialog.html#page_manual_gedialog_interaction_global_events
But the scope of EVMSG_CHANGE
is too wide and appears for many operations and not only windows/doc switching.
I tried to trace the msg IDs inside CoreMessage(), but I didn't found the correspondance for the IDs that I traced in console.
For example I'm getting this when switching between opened documents:
Python extract for the CoreMessage call,
def CoreMessage(self, id, msg):
doc = c4d.documents.GetActiveDocument()
# if id == c4d.EVMSG_CHANGE:
if msg.GetId() != 1298360653:
print ( f"COREMSG_ID {msg.GetId()}" )
In console,
COREMSG_ID 1937337955
I'm skipping the COREMSG_ID = 1298360653
otherwise I'm filing the console in a blink of an eye - it's maybe the redraw or evaluate scene.
I tried to explore the ge_prepass.h
file but didn't found any match. Where are located those ID Core Message definitions and their related readable values?
That would helps me to found the right ID message called when switching.
Then, I thought analyse the doc.GetDocumentName()
once I do know that I effectively switch from a document to an another.
If someone have some answers, just let me know, it would be really helpful!
Thanks!
Christophe