Python Integration?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/09/2012 at 10:44, xxxxxxxx wrote:

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

---------
Hi,

okay I can load and execute a python script but is there a way to extent the language with global variables or similar (just like for the Coffee engine)?

Thanks in advance

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/09/2012 at 11:19, xxxxxxxx wrote:

lib_python is not documented unfortuneately. 😞 Could you please post the code you use to execute a script? 🙂

Thanks,
-Niklas

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 30/09/2012 at 08:13, xxxxxxxx wrote:

I have no code I only found the example in the docs. Look out for ID_PYTHONSCRIPT.
I didn't know there was a pylib already. I check that, thanks for the hint. Anyway, at first glance I don't see anything that helps me with my question, so it would be nice if the support could give a direction or info on this.

On 12/02/2013 at 09:26, xxxxxxxx wrote:

Hi Samir,

Here's a small code example that shows how to add a global constant to c4d module:

void RegisterConstant()
{
    GePythonGIL gil; // gil must be created
    PythonLibrary pylib;
    
    _PyObject* mod = pylib.GetModule("c4d");
    if (mod)
    {
        pylib.InitConstant(mod, "constant", 30)
    }
}
  
Bool PluginMessage(id, data)
{
    switch (id)
    {
        case C4DPL_PYINITTYPES:
        RegisterConstant();
        break;
    }
    return true;
}

On 12/02/2013 at 11:23, xxxxxxxx wrote:

Thanks Yannick!