Skip to content

Instantly share code, notes, and snippets.

@rohanpsingh
Created May 31, 2023 05:07
Show Gist options
  • Save rohanpsingh/b2dc85e253a0322ff5878269194bf611 to your computer and use it in GitHub Desktop.
Save rohanpsingh/b2dc85e253a0322ff5878269194bf611 to your computer and use it in GitHub Desktop.
## Example command-line usage: $ for i in *.dae; do echo $i; blender -b --python convert.py -- $i ${i%.dae}.obj; done
## Need to be careful about face normals direction of exported object
import bpy
import sys
argv = sys.argv
argv = argv[argv.index("--") + 1:] # get all args after "--"
dae_in = argv[0]
obj_out = argv[1]
while bpy.data.objects:
bpy.data.objects.remove(bpy.data.objects[0], do_unlink=True)
bpy.ops.wm.collada_import(filepath=dae_in)
bpy.ops.export_scene.obj(filepath=obj_out, axis_forward='Y', axis_up='Z', use_materials=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment