Use Python modules without running Blender

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
freshquiz
Posts: 0
Joined: Thu Feb 09, 2012 11:24 pm

Use Python modules without running Blender

Post by freshquiz » Fri Feb 15, 2013 1:16 am

Hi everyone,

I wish to use the awesome power of Blender in a programmatic way, within my web application.

I know I can run something of the sort from the command line:

Code: Select all

blender foo.blend -P bar.py
, but I wish to maintain the security and cleanliness of my code by not invoking command line calls.

My web application is written in Python, hence my question is: what is the simplest way to separate the Blender python modules from Blender itself.

From what I understand Blender has a custom Python interpreter built into it, which is how it connects with the extended Python modules (written in C). To me this does not sound like good news for my goal, but does anyone know a way?

To be crystal clear, I want to be able to do this:

Code: Select all

import bpy

#Web application code...

bpy.ops.import_scene.obj(...)

#Web application code...
...without having to invoke 'blender' on the command line.

Cheers,
Matt

freshquiz
Posts: 0
Joined: Thu Feb 09, 2012 11:24 pm

Post by freshquiz » Fri Feb 15, 2013 7:17 am

This is what I was after, if anyone else comes looking: http://wiki.blender.org/index.php/User% ... AsPyModule

CoDEmanX
Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Fri Feb 15, 2013 1:35 pm

that page is also mentioned in the api docs:

http://www.blender.org/documentation/bl ... ricks.html
I'm sitting, waiting, wishing, building Blender in superstition...

Post Reply