23 from __future__
import print_function
29 argv = argv[argv.index(
"--") + 1:]
33 RATIO = float(argv[1])
35 THRESHOLD = int(argv[2])
38 print(
"Exporting collision meshes to <%s>." % mesh_dir)
40 scene = bpy.context.scene
42 for ob
in scene.objects:
45 bpy.ops.object.delete()
47 file_list = sorted(os.listdir(mesh_dir))
48 for file
in file_list:
50 if file.endswith(
'.dae') ==
True:
51 print(str(mesh_dir +
'/' + file))
52 bpy.ops.wm.collada_import(filepath= os.path.join(mesh_dir , file))
54 if(len(bpy.context.scene.objects[0].data.vertices) > THRESHOLD):
55 bpy.ops.object.modifier_add(type=
'DECIMATE')
56 mod = bpy.context.scene.objects.active.modifiers[0]
60 bpy.ops.object.modifier_apply(apply_as=
'DATA')
62 print (
" does not have enough vertices for DECIMATION")
64 bpy.ops.export_mesh.stl(filepath=os.path.join(output_dir,
65 file[0:file.find(
'.dae')]
66 +
"_" +
"{:.2f}".format(RATIO)+
".stl"))
68 bpy.ops.object.delete()
70 bpy.ops.wm.quit_blender()