Solved Is example ExecutePythonScript() also avialable in R19

Maxime pointed me this great example ExecutePythonScript() of running a python script from c++.

I succeeded to compile this example in R20.
Now, because we still have user running R19, I want to do the same in R19.

Is this possible?
Is there a similar example for R19.
Especially, setting scope variables is really good and what I need.

I can use the example from, but that one does not support scope variables (I guess).

The interfaces used in the ExecutePythonScript() are part of the python.framework, which was introduced with R20. So I guess that there is nothing equivalent in prior versions.

Yes, I think so too.

Hi Pim sorry for the late reply, this is possible by using the lib_py.h (typically this is somehow what we used before R20 to expose feature in python, but it's way elder, not everything is possible to do, you have less control than with the new python.framework, and the lib_py.h is not maintained (so don't expect any enhancement in it) Only the python.framework will be enhanced.

// Init Python
GePython pythonScope;

// Acquiere the GIL
GePythonGIL gil_state;

pythonScope.SetNode("doc", doc);
// If doc->GetFirstObject() is nullptr, op variable will not be declared in the python scope, and you cant add a None.
pythonScope.SetNode("op", doc->GetFirstObject());

maxon::String pythonCode = "\
import c4d\n\
def main():\n\
    print(doc, op)\n\
if __name__ == '__main__' :\n\