Re:Things You Can Do with Python and POV-Ray
by GrantS on Monday December 01, 2014 @12:28PM
(#8682326)
To follow up with a working example of python via headless blender on the command line, the following 4 lines interactively get me an image of a sphere saved to /tmp/.png
./blender -b --python-console
>>> import bpy
>>> bpy.ops.mesh.primitive_uv_sphere_add(size=3.0,location=(0,0,0))
>>> bpy.ops.render.render(write_still=True)
Re:Things You Can Do with Python and POV-Ray
by dirkk0 on Monday December 01, 2014 @12:46PM
(#8682443)
Great, thanks!
Does this work on a Mac and/or Linux?
Re:Things You Can Do with Python and POV-Ray
by zulko on Monday December 01, 2014 @12:58PM
(#8682532)
I just tested it on Ubuntu, it worked.
My point in the post was more that the embedded Python in Blender isn't really a "binding", it forces you to use Blender's 'internal' Python installation, so you must reinstall all the packages that you need specifically for Blender's Python (I don't know how, but I think there is a way). Also, this makes it impossible to use virtualenv, I guess (not sure).
In short, it would be cool if it just "worked from Python".
Re:Things You Can Do with Python and POV-Ray
by GrantS on Monday December 01, 2014 @12:58PM
(#8682536)
I ran this on a Mac, should work on Linux as well. Since it may not be obvious, the "blender" command line executable is located within the regular Mac OS X Application bundle for blender that you would download from the web:
/Applications/Blender/blender.app/Contents/MacOS/blender
(1) Blender 2.6, Python Manual with full API and Tutorials
http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/...
(2) Run python scripts through blender from command line:
blender -b -P script.py
blender -b --python-console (for interactive console)
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Comm...