plugin init order

On 06/01/2013 at 15:41, xxxxxxxx wrote:


is there a way to influence the order in which c4d is loading your  plugins when you have a 
multiple folder structure ? as an example :

---mainpluginfile.pyp (contains MainPluginClass)
---[SubPluginsFolder] (contains SubPluginClass)

c4d is loading these pluins in the order of the folder tree, MainPluginClass is being loaded 
first and after that SubPluginClass is being loaded. which causes some problems for me, 
because MainPluginClass needs SubPluginClass to exist on its initialization, because it
creates an instance of SubPluinClass in its constructor.

as a workarround i am listening with PluginMessage() for the id c4d.C4DPL_STARTACTIVITY
to call a Init() method in my MainpluginClass which then creates the instance of SubPluginClass.

is there a more elegent way to do this - or in other words, make c4d load SubPluginClass first 
and after that MainPluginClass ? I hope this does make any sense for you :)

On 07/01/2013 at 01:30, xxxxxxxx wrote:

It makes perfect sense and has been discussed here before. The situations when you want plugin 1 to load before plugin 2 aren't very common but they do occur, and unfortunately it seems that there's no way to guarantee it. I've been discussing this with David O'Reilly recently.

Matthias posted a while back that the plugins are loaded in alphabetical order, so renaming your subpluginfile to asubpluginfile should - most of the time - make it load before mainpluginfile. You may need to take it out of the subfolder to get it to work.

BUT - Windows doesn't guarantee this, even on NTFS and it won't work at all on FAT systems, although those are going to be very rare now. David quoted from the MSDN docs, which state that this behaviour is not guaranteed. We didn't bother looking at OSX. What I don't know is if Cinema sorts the plugins into name order before calling PluginStart for each one, which would ensure that this method works. It would be nice if Maxon support could confirm if that's the case or not.

In the end we found a way round that didn't need the second plugin, but if you really need it then try the name order method. If it works for you, it will probably work for all your users. Probably.


On 07/01/2013 at 08:02, xxxxxxxx wrote:

hey steve,

first of all, thany you very much for your precise answer. this whole file naming thing seems to 
be rather risky for me. i personally do not really understand why they loading order is not tied
to the order of the plugin IDs, because this is the behaviour at least I have been expecting. 
however, it seems that i have to stick with PluginMessage() or that i have to change the point 
when my MainpluginClass creates the the SubPluginClass instance.

On 07/01/2013 at 08:18, xxxxxxxx wrote:

Hi Ferdinand,

For C++ Plugins, one can use SetPluginPriority() from PluginMessage() when C4DMSG_PRIORITY is
sent. Unfortuneately, this function is not wrapped in Python nor PluginMessage() is called for this
type of message.

I also think you have to stick with your workaround. Maybe I can find a way to make this more
elegant, this would be something for the c4dtools library then. :)

PS: Shouldn't your should end with .pyp?


On 07/01/2013 at 08:25, xxxxxxxx wrote:

Hi Niklas,

From the testing I did, SetPluginPriority didn't seem to make any difference. Otherwise it would have been a nice solution. But of course I may not have used it correctly.

On 07/01/2013 at 08:56, xxxxxxxx wrote:

Originally posted by xxxxxxxx

PS: Shouldn't your should end with .pyp?

lol, sure it should be :)

On 08/01/2013 at 08:52, xxxxxxxx wrote:


C4D depends on the OS here, so an order is not garantueed, especially on FAT Windows loads the plugins in the order how they were written on disk. On NTFS the order is usually alphabetically. Unfortunately both is marked by MS as "not garantueed" explicit.

The order for python plugins might be controlled in the future. Until this problem is solved you might put the startup code for your plugins in a special function. The plugin which starts first initializes itself on startup and then sends a global message which is catched by the plugin which needs to load afterwards. Then you call your special function.

Cheers, Seb