Creating Python callbacks in Custom OPs

Hi guys,

got a few questions. I have never done much Python-C or Python integration with C++, so, I thought I would ask these questions here.

I am trying to achieve the following things:

  1. I would like to create a Python callback function, so, when data comes into my custom OP. I can call the Python callback and let the user process the data in Python. What’s Derivative’s guideline on doing that? The solutions available out there are Python.h, Boost.Python and pybind11. But before I invest a lot of time on any of them, I would like to know if there is an official way of implementing this?

  2. I would like to create a function in my C++ code that the user can call via Python.

  3. I would like to create a docked text DAT that contains a sample template function that the user can edit and implement their own code. In my head, I imagine I can try and get a Python object that represents my op’s COMP parent, and then call create, dock, and probably inject the sample code into the text dat.

However, that would require me to get a hold of the Python object associated with my op. How would I go about doing that? The most obvious way I can find is creating a custom python param, put in a default value of “me,” and then call getParPython. But that just seems really round about. Is there a way to do it without doing this?

Thank you!


1 Like