How to get list of all MyPlugin instances?

On 04/08/2018 at 05:32, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   19 
Platform:   Windows  ;   
Language(s) :     C++  ;

At first, I thought that it's a very simple task.. My mistake.:-/

What I tried to do is to create global storage and save link to plugin instance every time it's being created:
< <<Main.cpp>>>

def PLUGIN_ID = 1234321  
class MyTagPlugin: TagData {  
GePrint("---MyTag constructor---");  
Bool MyTagPlugin::Init(GeListNode *node)
    pluginStorage = GetActiveDocument()->GetDataInstance()->GetContainer(PLUGIN_ID);
    index = bc.GetInt32(0,0)+1;
    pluginStorage.SetLink(index, (BaseTag* )node);
Bool PluginMessage(Int32 id, void *data)
        GePrint("Creating plugin storage");
        GetActiveDocument()->GetDataIstance()->SetContainer(PLUGIN_ID, BaseContainer());

< <<Output>>>

Creating plugin storage
---MyTag constructor---
---MyTag constructor---

Why Constructor and Init functions of my plugin are fired twice when each instance of it created and twice every time when I change any parameter of MyTag?

What event or function should I use instead, to catch the moment of MyTag creation?

On 06/08/2018 at 02:50, xxxxxxxx wrote:


indeed you can not rely on Init() (or the constructor) being called just once. There are several reasons for this, one for example is related to the undo system. The correct way to be informed about the creation of your tag is to listen to the (admittedly strangely named) message MSG_MENUPREPARE. This message is sent, when the user creates a new tag from the menu (and is meant to do additional preparational work, thus its name).

May I ask, why you are trying to set up such a global directory of tag instances?

In that regard also you use of PluginMessage(C4DPL_COMMANDLINEARGS) looks a bit strange to me. The user might be working with multiple documents in parallel later on. Or he might close the scene and open a new one. The more correct approach would be, to check the existence of your BaseContainer later on, when you actually want to access it, and then create it on the fly if needed.

On 18/08/2018 at 09:52, xxxxxxxx wrote:

Hi, Andreas.

May I ask, why you are trying to set up such a global directory of tag instances?

What I wanted to create is some kind of visibility switcher that gonna let me easely show/hide different groups of objects in my scene.

Each instance of MyTag "knows" 4 things:
1)parameter number (i mean [c4d.ID_USERDATA,param_num] of controller object)
2)active parameter value
3)active layer
4)inactive layer

I'm creating controller object which contains different parameters, and when value of some parameter is changed, python script sends message to all instances of MyTag with number of parameter that was changed and it's new value. (* )
If (new_value==active_value) then (layer=active_layer), else (layer=inactive_layer)

> (* ) _That's the step where I needed whole list of MyTag-s. I avoided this problem by creating MyTag list within my python code.
> _

UPD (offtopic) :
BTW, Andreas, there's definetely something wrong with photometric light sources in C4D.
I wrote about it here:

Here are some IES files to check:
I think it's a bug.

On 24/08/2018 at 06:17, xxxxxxxx wrote:


I'm actually not quite sure, if we still have an open question here. Please forgive.

For the IES lights I'd recommend to submit the bug to our user support: How can we help?