4
$\begingroup$

I intend to make a framework for BGE using wxPython, being able to manage blend file libs, datablocks of the blends, alternative ways to make logic and ease the project management in general. I need to use Blender to edit the blend files contents (add logic bricks, edit datablocks, etc), so at first I thought to call blender in background mode through command line and execute Python scripts generated by the framework to make the changes to the blends. However, that would imply to open blender (in background) and save the blend file for each operation, even the simplest ones (like renaming), or queue the changes and add a annoying 'Apply' button. So, I wonder if it's possible to 'take control' of Blender's Python using the framework's Python, so the user can see the changes by the framework in real-time while being able to do changes that the framework won't do (like modeling, texturing, animation, etc). Is that possible? Thanks.

$\endgroup$
2
  • $\begingroup$ The ‘exec_from_stdin.py’ example from blender.stackexchange.com/a/101772/29586 is very similar - allows you to effectively pipe the output from one command into Blender to be invoked as python commands. However, it won’t work as-is on Windows - Linux (and possibly Mac) only. $\endgroup$ Commented Mar 19, 2018 at 10:17
  • $\begingroup$ Would it be possible to fire up your framework from inside Blender, so the Python running your framework is already the same one that's controlling Blender? $\endgroup$
    – ajwood
    Commented Jun 11, 2019 at 12:12

1 Answer 1

3
$\begingroup$

You'll have to build it yourself, but you can build Blender as a Python module. You can then do import bpy and use it as if you're inside Blender.

Update 2024: nowadays you can just use pip install bpy and grab the module from https://pypi.org/project/bpy/

$\endgroup$
1
  • 1
    $\begingroup$ The wiki was archived, I've copied the page to the new wiki. $\endgroup$
    – dr. Sybren
    Commented Jun 11, 2019 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .