How do you write commands in blender from a python script run outside blender?

666 views Asked by At

I am trying to find a wat to add virices in a subprocess.Popen opened blender using the script that opened it to write the bpy codes into the blender proces. If this isn't possible, is there a wat to make the blender python receive (through a script run in blender) messages from the python script run in terminal (I am using fedora)

Thanks in advance

1

There are 1 answers

1
jsbueno On BEST ANSWER

Indeed - you have thought half the answer for yourself - The blender modules won't be available from outside blender, but you can have a script inside blender to receive data from outside.

The easiest way would be to use XMLRPC - use a script that loads with Blender, and stars a Python XMLRPC server - then you will be able to send commands into that script from outside.

It is easier than it sounds - check the Python documentation for XMLRPC (it will even allow you to have python 2.7 scripts outside blender communicating with the Python 3 that runs inside blender) -

http://docs.python.org/3.3/library/xmlrpc.server.html#module-xmlrpc.server