Exposing object functions to python



  • On 14/04/2014 at 03:08, xxxxxxxx wrote:

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

    ---------
    Is it possible to expose custom functions from a subclass of ObjectData into python? Or at least create a global function that takes it the object as an argument, so I can handle it in C++ and return the information I need? I need access to the underlying data structures..

    I only found this example for wrapping a global function using ctypes here. But have no idea how I could use it for my purpose.

    Cheers,
    Satara



  • On 17/04/2014 at 14:54, xxxxxxxx wrote:

    The Python API is not documented, we therefore also don't give much support for it, but you can
    use it. It should not be hard to understand after examining the header a little. Something that you
    should know though (where I failed initially) is that you need to lock the Python GIL before doing any
    Python related stuff. You can use RAII for that purpose with the GePythonGIL class.

    The Python library in the SDK allows you to convert back and forth between GeListNodes, for 
    instance. You can also expose new functions to Python, but it might be easier to just use ctypes
    and then convert the passed PyObjects to a GeListNode.

    Best,
    -Niklas


Log in to reply