Last active
February 14, 2022 13:43
-
-
Save nebadon2025/8525f19c88c51a22a285ab283b0339fc to your computer and use it in GitHub Desktop.
Batch FBX Importer for Blender Python
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
import os | |
import bpy | |
# put the location to the folder where the FBXs are located here in this fashion | |
# this line will only work on windows ie C:\objects | |
path_to_obj_dir = os.path.join('C:\\', 'objects') | |
# get list of all files in directory | |
file_list = sorted(os.listdir(path_to_obj_dir)) | |
# get a list of files ending in 'fbx' | |
obj_list = [item for item in file_list if item.endswith('.fbx')] | |
# loop through the strings in obj_list and add the files to the scene | |
for item in obj_list: | |
path_to_file = os.path.join(path_to_obj_dir, item) | |
bpy.ops.import_scene.fbx(filepath = path_to_file) | |
# if heavy importing is expected | |
# you may want use saving to main file after every import | |
bpy.ops.wm.save_mainfile(filepath = "C:\\To\\Your\\File.blend") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment