3
$\begingroup$

I have never done scripting in Blender, so I am looking how to solve this task. I have 1000 OBJ files that I have to import in Blender one by one, and to render each one under the same setting. The workflow is roughly like this:

  • import the OBJ
  • rotate and scale the object (constant value)
  • create a plane at z=0
  • put a lamp at a specific location
  • render the image
  • move the lamp to a second specific location
  • render the second image

And this has to be done 1000 times (for each OBJ).

I am proficient with Python if it helps.

$\endgroup$
2
  • 1
    $\begingroup$ You could start here, Batch import Wavefront OBJ. $\endgroup$
    – iKlsR
    Commented Apr 14, 2014 at 17:48
  • 1
    $\begingroup$ You could try using the Info panel to help find the names of some operators, but also have a look at the api docs $\endgroup$
    – gandalf3
    Commented Apr 14, 2014 at 20:21

1 Answer 1

3
$\begingroup$

You will get the API calls for free by pulling down the Info Header as shown here:

enter image description here

Just perform the scene setup manually, select all lines A and copy'n paste the commands into a python file. You might want to add the snippet from the comment by iKlsR.

bpy.ops.view3d.snap_cursor_to_center()
bpy.ops.mesh.primitive_plane_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.ops.transform.resize(value=(6.39051, 6.39051, 6.39051), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
bpy.ops.object.lamp_add(type='HEMI', view_align=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
bpy.ops.transform.translate(value=(0, 0, 6.98471), constraint_axis=(False, False, True), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
bpy.ops.transform.translate(value=(0, -6.91949, 0), constraint_axis=(False, True, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, release_confirm=True)
bpy.ops.transform.rotate(value=-0.645382, axis=(-0.818828, 0.361665, -0.445779), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
bpy.context.space_data.context = 'RENDER'
$\endgroup$
1

You must log in to answer this question.

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