Calling a Python plugin from C++ PluginStart()
-
Hi all,
is it possible to call a Python plugin (.pyp) from within a C++ plugin's PluginStart()?
In which order are modules and plugins initialised on application startup?I am trying to call a Python plugin from C++ PluginStart(), and I do not get an error. However, the plugin I call doesn't react either. My guess is that Python is already initialised, but the Python plugin I want to use has not been loaded yet.
Is there a way to set a Python plugin's init priority? In the C++ SDK, a function called "SetPriority();" is still mentioned, but not documented anymore. In Python, it doesn't seem to exist. The C4DPL_INIT_ constants are still there.
If I call the Python plugin from PluginMessage w/ C4DPL_STARTACTIVITY, it works. But I would really like to call the Python plugin before the C++ plugins are being registered.
thanks & greetings,
Frank -
Hi @fwilleke80, unfortunately, it's not possible since python in Cinema 4D is by design only a reflexion of C++. So by design python plugin are loaded after all plugins.
May I ask you why you need such a python call as early as that?
Cheers,
Maxime. -
I'm using a Python plugin to make HTTP requests on our update and activation server. The idea was to have it check for updates and valid license before the actual plugins get registered.
And yes, I could write the request part in C++, but supporting R16 to R21 would mean a lot of work in C++, while the same Python code works across all these releases.
Cheers,
Frank -
If it's only a question of executing python, why not directly execute python from C++ using the python library?
#include "c4d.h" #include "lib_py.h" PythonLibrary pylib; pylib.Execute("import c4d\nprint 'From Python:', c4d.GetC4DVersion()"_s);
Note that in R20 the python.framework was released, and should be used for the future.
The old python library (since R15) is still there and still works, but take care that in a future release it may disappear since everything that was possible and even more is now possible with the python.framework.For more information see Python Page.
Cheers,
Maxime.