THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/01/2012 at 04:04, xxxxxxxx wrote:
Hello,
I would like to know if there was any possibility to obtain the memory adress of a wrapped object from the C4D-API in Py4D. And if not, why isn't there? This would expand the possibilities of Python in Cinema 4D even more. Writing expensive algorithms in C++ and wrap it all with the ease of Python, that'd like cake (and I really love cake)! Yes, we would loose platform independency when using this technique, and needed to compile the C++ implementation for each platform. But hey, the C++ guys do it the same way, except they don't use Python to interface between the user and C++.
import c4d
import ctypes
myextension = ctypes.cdll.myextension
op = c4d.BaseObject(c4d.Ocube)
myextension.doStuff(op.GetCPointer())
#include <c4d_baseobject.h>
DLLEXPORT void doStuff(long ptr) {
BaseObject* op = (BaseObject* )ptr;
// go on doing c++ stuff
}