Message when user switches document
-
On 20/10/2017 at 02:46, xxxxxxxx wrote:
I have an object plugin and I want to know when the user switches documents.
What message, and where, do I receive when the users switches back to the document with the object plugin in it?I tried this, but it does not work (do I receive CoreMessage() in an object plugin?) :
def CoreMessage(self, id, msg) : #print "id: ", id if id == c4d.MSG_DOCUMENTINFO: print "document info" return True
-Pim
-
On 20/10/2017 at 08:04, xxxxxxxx wrote:
I'm not sure but I remember read something about MSG_DOCUMENTINFO are not implemented in python since DocumentInfoData is not aviaible but I could be wrong.
-
On 20/10/2017 at 10:00, xxxxxxxx wrote:
I am not really interested in the reason for the doc change, so this working:
if type == c4d.MSG_DOCUMENTINFO:
....Thanks, Pim
-
On 23/10/2017 at 02:59, xxxxxxxx wrote:
Hi Pim,
MSG_DOCUMENTINFO is not a core message but a node message, so it is sent to Message(). (Note object plugins does not receive core messages.)
The message is sent for several document handling scenarios (load, merge, save, remove, undo, etc.), so its type has to be checked as well.
And the data for MSG_DOCUMENTINFO is passed as dictionary like other messages.The following code checks when the document was set as active:
def Message(self, node, type, data) : if type == c4d.MSG_DOCUMENTINFO: if data['type'] == c4d.MSG_DOCUMENTINFO_TYPE_SETACTIVE: print "Document holding object was set active" return True return True
The Python documentation for MSG_DOCUMENTINFO is not accurate and lacks details (applies to other messages). This will be fixed and improved.