Integrating custom c++ code into Python scripted plugin?

67 views
Skip to first unread message

AK Eric

unread,
Nov 20, 2015, 3:09:16 PM11/20/15
to Python Programming for Autodesk Maya
Asking for an engineer, since this isn't something I've ever tried:

He wants to integrate some custom (non-Maya) c++ code into a Maya plugin.  I have experience doing scriptedPlugins in Python, but not c++ ones. 

Obviously if you make a c++ plugin it'd be easy to integrate this other code.  So the question is:  Can you call to custom c++ code from a Python scripted plugin?  Or wrapper it somehow... or.... ?

Any thoughts?

thanks!

Joe Weidenbach

unread,
Nov 20, 2015, 3:24:00 PM11/20/15
to python_in...@googlegroups.com
Interesting Question.  I'm pretty sure it could be done.  There's lots of ways available to wrap custom c++ code with a Python Binding, and I know that in the past I've called into COM interfaces on windows (to drive Photoshop) from my python scripts, but I'm not sure on the "how" for custom code.  

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f3be53da-1894-4b77-8645-f60d2d8d74cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Nov 20, 2015, 3:30:44 PM11/20/15
to python_in...@googlegroups.com
I'm not an engineer, but hopefully you don't mind if I give this one a shot. :)

Step 1, write your C++ code.
Step 2, create bindings for Python

For step 2, you can use any of these.

- sip (from PyQt-land)
- shiboken (from PySide-land)
- Boost.Python
- pybind11
- ...

You compile it against the Python that ships with Maya, and viola, a regular importable library, like PyQt or PySide.



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

satoh

unread,
Nov 20, 2015, 3:45:11 PM11/20/15
to python_in...@googlegroups.com

Justin Israel

unread,
Nov 20, 2015, 4:42:36 PM11/20/15
to python_in...@googlegroups.com


On Sat, 21 Nov 2015 9:30 AM Marcus Ottosson <konstr...@gmail.com> wrote:

I'm not an engineer, but hopefully you don't mind if I give this one a shot. :)

Step 1, write your C++ code.

Step 2, create bindings for Python

For step 2, you can use any of these.

- sip (from PyQt-land)

- shiboken (from PySide-land)

- Boost.Python

- pybind11

- ...

Adding on..

- Cython

- Built in ctypes library if you write a C shim

- Expose it to python through a Maya commands plugin that takes parameters



--

Marcus Ottosson
konstr...@gmail.com

To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBp5Wgkcx7JY2Acs%2BAELGtqpym4RS_1aqBKeN2cD9%3D0Vg%40mail.gmail.com.

AK Eric

unread,
Nov 20, 2015, 5:19:56 PM11/20/15
to Python Programming for Autodesk Maya
Thanks everyone, I'll pass that along.
Reply all
Reply to author
Forward
0 new messages