Skip to content

Instantly share code, notes, and snippets.

@AlecTaylor
Last active January 20, 2016 00:21
Show Gist options
  • Save AlecTaylor/b6b8878df5534b7fb3ce to your computer and use it in GitHub Desktop.
Save AlecTaylor/b6b8878df5534b7fb3ce to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from os import path
from sys import argv, stderr
import bpy
def main():
args = argv[argv.index('--') + 1:]
# format specific options... change as you like
args_fbx = dict(
# global_scale=1.0,
)
args_obj = dict(
# use_image_search=False,
)
args_3ds = dict(
# constrain_size=0.0,
)
args_stl = dict(
use_scene_unit=True
)
for filepath in args:
ext = path.splitext(filepath)[1].lower()
{'.fbx': bpy.ops.import_scene.fbx(filepath=filepath, **args_fbx),
'.obj': bpy.ops.import_scene.obj(filepath=filepath, **args_obj),
'.3ds': bpy.ops.import_scene.autodesk_3ds(filepath=filepath, **args_3ds),
'.sty': bpy.ops.import_mesh.stl(filepath=filepath, **args_stl)
}.get(ext, print('Extension {!r} is not known!'.format(ext), file=stderr))
else:
print('No files passed', file=stderr)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment