Multiple View Port Image Render Command Line

Blender's renderer and external renderer export

Moderators: jesterKing, stiv

tsa256
Posts: 5
Joined: Sun Aug 19, 2012 5:53 am

Multiple View Port Image Render Command Line

Postby tsa256 » Sun Aug 19, 2012 5:59 am

Hello everyone, I've been using blender for a while now as a hobby but recently started a project and need some help.

Basically, I'm trying to get Blender to render 3 or 4 views of a 3D model via command line. Preferably, I'd be able to automate the process so that Blender can open any compatible 3D model file and render images from different views. Views such as top, right, front, auxiliary would be very useful.

Does anyone know how or if it's even possible to automate this. I'd rather not have to manually open blender GUI and set up frames and cameras. The 3D model files will not be animated so would it be possible to set up a template with frames and cameras setup then import the 3D model?

Thanks in advance.

stiv
Posts: 3646
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Postby stiv » Sun Aug 19, 2012 4:53 pm

Blender -h is your friend here.

tsa256
Posts: 5
Joined: Sun Aug 19, 2012 5:53 am

Postby tsa256 » Mon Aug 20, 2012 12:17 am

stiv wrote:Blender -h is your friend here.


Yes, I have done previous research and attempted to get something working. I've been able to render one frame from command line using

# blender -b file.blend -o //file -F JPEG -x 1 -f 1

and from reading http://wiki.blender.org/index.php/Doc:2 ... mmand_Line I know you can render multiple frames. However, this does not entirely answer my original question. Now that I have got rendering down, how would I go about importing/converting an object into blender such that I can render the frames without going into the GUI.

Thanks for the help.

tsa256
Posts: 5
Joined: Sun Aug 19, 2012 5:53 am

Figured out rendering, now import model?

Postby tsa256 » Mon Aug 20, 2012 9:52 am

So I managed to piece together a Python script that creates a camera and orients the camera for a variety of different views and renders a corresponding image.

Now my question is, how would I go about importing a model; such as a stl or obj into blender then running my script on the file. At the moment my script only runs from inside blender with GUI and a file already open. Keep in mind I'm trying to automate this entire system so no GUI is needed. Perhaps you could point me in the right direction.

Thanks

stiv
Posts: 3646
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Postby stiv » Mon Aug 20, 2012 3:38 pm

The -P option lets you run a python script.

tsa256
Posts: 5
Joined: Sun Aug 19, 2012 5:53 am

Getting There

Postby tsa256 » Tue Aug 21, 2012 2:50 pm

stiv wrote:The -P option lets you run a python script.


Thank you, that was simpler that I thought. I got most of what I'm trying to do done but I ran into another problem, and perhaps this should go into another thread.

Basically, now that I can import a model into blender I am attempting to "zoom to fit" the camera to the object. The equivalent to: View >> Align View >> Center Cursor and View All or Shift + C within the GUI

From looking at the context I assumed I would just use

Code: Select all

 py.ops.view3d.view_all(center=True)


However, that yields an error RuntimeError: Operator bpy.ops.view3d.view_all.poll() expected a view3d region.

After searching around I believe this is because that command polls the GUI for information about what is currently selected or what region is currently active? I'm not 100% sure but that's what is seams like. After more searching it appears that I need to override the context. This capability is fairly new and I haven't found too many examples that have worked. Here is what I have tried.

Code: Select all

for window in bpy.context.window_manager.windows:
    screen = window.screen
   
    for area in screen.areas:
        if area.type == 'VIEW_3D':
            override = {'window': window, 'screen': screen, 'area': area}
            bpy.ops.view3d.view_all(override)
            break


I've looked at http://www.blender.org/documentation/bl ... ng-context which helped a little bit but I'm still unsure of the correct syntax. I've tried numerous derivatives of the cod to no avail.

Thanks for the help.

tsa256
Posts: 5
Joined: Sun Aug 19, 2012 5:53 am

Postby tsa256 » Wed Aug 22, 2012 7:33 am

I solved the problem. I was mistakenly using Blender 2.6.3.0 and not 2.6.3.5 and I needed to place region within the context override.


Return to “Rendering”

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests