Hello @mikeudin,
Thank you for reaching out to us.
But it's seems is not working in this case. Is it possible to know when user changes active document in case of CommandData plugin?
The posting you are referring to states that
"MSG_DOCUMENTINFO
is [...] a node message"
A little bit more precise would be to say it is an atom message, i.e., it is only being sent to C4DAtom
instances via C4DAtom.Message()
. A CommandData
plugin is not an atom and its message method is part of another message stream.
I would recommend having a look at the Python Message System Manual, as it lines out how messages work, and what kind of messages to expect in CommandData.Message
.
Long story short, no, you will not find a message that signals the active document having been changed to a CommandData
plugin. You will have to hook into other messages and manually check. The messages you could range from very broad as EVMSG_CHANGE
(which is being broadcasted very often) to slightly more specific message IDs like, for example EVMSG_DOCUMENTRECALCULATED
. I cannot tell you which one works best for your use case, I would have to try myself. Another approach would be to implement a NodeData
plugin and broadcast the information from there to your CommandData
. The problem is that Python lacks a good NodeData
type for that, as is lacks the SceneHookData
type which would be the natural choice in C++. You can use some of the other NodeData
types in Python like ObjectData
or TagData
, but you should know that some atom messages are not being sent to all atoms, as Cinema 4D considers them irrelevant for these plugins. MSG_DOCUMENTINFO
is one of these messages, and it is for example not being broadcasted to PreferenceData
, which otherwise could serve as a replacement for a SceneHookData
, as it is a node which has not to be instantiated as for example an object or tag must be.
Cheers,
Ferdinand