blender2.79通过python脚本快速批量导入fbx

废话不多说直接上代码

import bpy 
import os 

in_dir = "D:\\Models" # fbx目录
filters = ["ss.fbx"] # 过滤的fbx文件

def import_need_fbx(path, filters):
	need_file_items = []
	need_file_names = []

	filterDict = {}
	for item in filters:
		filterDict[item] = True;

	file_lst = os.listdir(path)

	for item in file_lst:
		fileName, fileExtension = os.path.splitext(item)
		if fileExtension == ".fbx" and (not item in filterDict):
			need_file_items.append(item)
			need_file_names.append(fileName)

	n = len(need_file_items)
	for i in range(n):
		item = need_file_items[i]
		itemName = need_file_names[i]
		ufilename = path + "\\" + item
		bpy.ops.import_scene.fbx(filepath=ufilename, directory=path,filter_glob="*.fbx")
		if (bpy.data.objects[itemName]):
			bpy.data.objects[itemName].hide = False
			bpy.data.objects[itemName].hide_render = True

import_need_fbx(in_dir, filters)

使用是
blender2.79通过python脚本快速批量导入fbx_第1张图片

这样打开指定的文件

你可能感兴趣的:(blender)