2
$\begingroup$

I have thousands of .smd files I need to convert to .fbx files. I have an add-on that lets me import .smd files, but going one by one will obviously take forever. I need the script to search the main directory and all sub-directories for the .smd files.

I'm assuming this is how the script would work:

  • Get main directory and sub-directories
  • Put all of the .smd files in a database or something
  • Factory Restart Scene
  • Delete all objects in the scene
  • Import a .smd file
  • Export the .smd file as a .fbx without replacing the original
  • Remove from list in the database?
  • Loop back to the beginning until no files are left?

I know nothing about python, please help me.

$\endgroup$
1
  • 1
    $\begingroup$ This is perhaps a better question for stack overflow. $\endgroup$
    – JakeD
    Commented Sep 8, 2016 at 1:52

1 Answer 1

4
$\begingroup$

Python isn't hard to start learning, try this tutorial. You can use the python console in blender if you don't have python already installed.

You don't need to create a database as you can walk through all files in the directories and just use the filesystem as a todo list. This is the basics of what you want to do but you may want to make some adjustments, you will at least have to swap bpy.ops.import_scene.obj for the smd importer that you have.

import bpy
import os

for root, dirs, files in os.walk('/path/to/smd/files'):
    for name in files:
        if name.endswith('smd'):
            # delete everything
            bpy.ops.object.select_all(action='SELECT')
            bpy.ops.object.delete()
            # adjust this to match the import smd operator
            bpy.ops.import_scene.obj(filepath=os.path.join(root, name))
            # export as fbx
            bpy.ops.export_scene.fbx(filepath=os.path.join(root, name+'.fbx'))

You can paste this into blender's text editor, edit and then click the run script button.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .