Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hello guys, I am trying to detect when a tag is enabled/disabled(here target camera specifically). For that purpose I am looking at the messages coming from cinema4d. While I can identify the messages id pattern: I receive 604, 1018484 and then 1685218156. I cannot retrieve from which message those ID belong to.
I Also noticed, that I receive the same message when I click on the button located on the left of Enable (see image below).
Thank you in advance for your reply. Best
If you want to know from within the TagData-derived object the enable state of the tag you can (with a method receiving a GeListNode* node as argument) do:
BaseTag* tag = (BaseTag*)node; Bool enabled = false; if (tag) { GeData d; tag->GetParameter(<your tag's ENABLE-id>, d, DESCFLAGS_GET::NONE); enabled = d.GetBool(); } ...
If you want to get triggered by the change of state then:
Bool YourTagDataDerivedClass::Message(GeListNode* node, Int32 type, void* data) { if (type == MSG_DESCRIPTION_POSTSETPARAMETER) { DescriptionPostSetValue* postsetval = static_cast<DescriptionPostSetValue*>(data); if (postsetval && (*postsetval->descid == DescID(<your tag's ENABLE-id>))) ... and same as above: you get the state of the enable-parameter
Bool YourTagDataDerivedClass::SetDParameter(GeListNode* node, const DescID& id, const GeData& t_data, DESCFLAGS_SET& flags) { if (!node) return false; const Int32& gadgetID = id[0].id; switch (gadgetID) { case <your tag's ENABLE-id>: enabled = t_data.GetBool();
Thank you for your reply, I guess there is no way to observe a tag if you are not implementing it.
Best
Hello @user168462,
Thank you for reaching out to us. You said,
"I guess there is no way to observe a tag if you are not implementing it."
It depends a bit on how you mean that and how you mean your question in general. @C4DS gave you already a very nice answer (thanks for that). There are basically two scenarios (which effectively will become one):
BaseTag
One might be tempted to solve option 1 by simply storing a pointer to that BaseTag and then periodically look up the tag to track changes. But this will not work due to node reallocation. This problem can be solved by either using the Baselink type or by manually traversing a document tree/graph and identifying nodes by their unique id stored under MAXON_CREATOR_ID. This second approach (traversing the whole document tree) is also what is the solution to option 2.
MAXON_CREATOR_ID
To carry out the periodical checking, the most straight forward option is to the core message EVMSG_CHANGE. You can do this in a MessageData plugin or GeDialog derived GUIs. An alternative approach is to implement a SceneHookData plugin and do the traversing in its Execute() method.
EVMSG_CHANGE
MessageData
GeDialog
SceneHookData
Execute()
TLDR: While the Cinema 4D classic API does not have a dependency graph or a very granular event system, scene changes can be tracked with EVMSG_CHANGE. It is only that it is up to the user to find out if the change that occurred is of relevance as Cinema 4D does not give any context for the cause of EVMSG_CHANGE.
Cheers, Ferdinand