Created
May 21, 2014 09:27
-
-
Save PierrickKoch/b2061bd6cc5f1d13f56d to your computer and use it in GitHub Desktop.
Collada to Wavefront (.dae to .obj) -- see http://www.blender.org/documentation/blender_python_api_2_70a_release/bpy.ops.export_scene.html#bpy.ops.export_scene.obj
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
""" | |
Collada to Wavefront (.dae to .obj) | |
usage: blender -b -P dae_obj.py -- in.dae out.obj | |
""" | |
import sys | |
import bpy # Blender Python API | |
def setup(): | |
""" Setup the scene """ | |
# Delete the default objects | |
bpy.ops.object.select_all(action='SELECT') | |
bpy.ops.object.delete() | |
def usage(): | |
sys.stderr.write(__doc__) | |
def convert(fdae, fobj='out.obj'): | |
bpy.ops.wm.collada_import(filepath=fdae) | |
bpy.ops.export_scene.obj(filepath=fobj) | |
def main(argv=[]): | |
args = [] | |
if '--' in argv: | |
args = argv[argv.index('--')+1:] | |
if len(args) < 2: | |
usage() | |
return 1 | |
fdae = args[0] | |
fobj = args[1] | |
setup() | |
convert(fdae, fobj) | |
if __name__ == '__main__': | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment