Last active
January 12, 2018 08:05
-
-
Save champierre/c11dd8693499c7d3b9c7317f63c9acb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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