Skip to content

Instantly share code, notes, and snippets.

@champierre
Last active January 12, 2018 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champierre/c11dd8693499c7d3b9c7317f63c9acb6 to your computer and use it in GitHub Desktop.
Save champierre/c11dd8693499c7d3b9c7317f63c9acb6 to your computer and use it in GitHub Desktop.
import bpy
import sys
if __name__ == "__main__":
# Get object file path from 1st argument after "--".
# Get png file path from 2nd argument after "--".
argv = sys.argv
argv = argv[argv.index("--") + 1:] # get all args after "--"
obj_file = argv[0]
png_file = argv[1]
# Remove cube object that is added in default
bpy.data.objects.remove(bpy.data.objects['Cube'])
# Import object file
bpy.ops.import_scene.obj(filepath=obj_file)
# Export rendered image to png file
bpy.ops.render.render()
bpy.data.images['Render Result'].save_render(filepath = png_file)
# Quit Blender
bpy.ops.wm.quit_blender()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment