Integrating my own programs

Hello there,

I’m having trouble phrasing this question in english I would bet, because although this is likely a simple task google hasn’t been very good at answering. So,

I’d like to teach Blender to pick up a compiled program (I’m on windows so only .exe for now) and run it for me; reckon it might help with certain computations too expensive for python alone. However this would mean dealing with pipes, and I can’t find a good place to begin thinking about it.

Any thoughts?

Blender does not use Python for heavy computations which is why the Blender Python API does not allow for the creation of custom made modifiers.

So Blender Python already relies on Blender source code which is written in C and is usually very fast.

Of course you can write your own C code and or use and existing C library like Numpy that is included with Blender via Python to do heavy computations. Speed is not a problem for Python , problem is that if you go full speed in Python you are basically start writing C code in Python . Which means you have to sacrifice everything that makes Python fun and easy to use so its no wonder that people choose instead to go straight to C and call that code then from Python.

A pipe wont help you here, Python is embeded inside the Blender executable , instead of being a separate executable .

You can also use Python libraries no included with Blender that are known for their performance. Or specialised tools that greatly speed up Python code like Cython.

If you want to call an external application and communicate with it , pipes, sockets and shared memory maped files can be used. Depending on your needs for remote execution, speed and cross platform compatibility.

Very informative, thank you.

Seems like a good place to start. I’ll see what goes into a simple function call and go from there.

You could use a pipe to communicate with a separate compiled executable.

"What? You actually require the two programs to run asynchronously?" You cannot, for example, run the first program, directing its output to a disk file, then run [Blender …], telling it to now read the content of that file?

To fully understand the best solution for this use-case, you need to please tell us a great deal more about it. Start at the beginning … :smiley: (Plenty of experts here …)

It depends entirely on what the .exe file supports. Most seem to only work with file interchange, where you specify which file you want to use in the command line. It’s very easy to do this in Python using the subprocess module and the call function.

What I originally thought about, nearly a month ago, was sending input to a external program from Blender, run that program and receive it’s output in Blender; but it’s basically write a few library functions in C and call that code from python, so now I’m thinking I’d rather just do that.