# 遍历每个obj文件 for a in glob.glob(os.path.join(obj_path,'*.obj')): # 导入obj文件 objname=os.path.basename(str(a)) bpy.ops.import_scene.obj(filepath=os.path.join(obj_path,str(a))) # 新建gltf文件夹 gltf_path=os.path.join(obj_path,"gltf") createfolder(gltf_path) # 清除所有选择 objects = bpy.context.collection.objects [obj.select_set(False) for obj in objects] # 选择所有模型然后导出 [obj.select_set(True) for obj in objects] exportgltf(objname) # 删除所有模型 mesh_to_delete = [] for ob in bpy.context.selected_objects: mesh_to_delete.append(ob.data) bpy.ops.object.delete() for me in mesh_to_delete: bpy.data.meshes.remove(me)
This piece of writing is an original article, utilizing theCC BY-NC-SA 4.0Agreement. For complete reproduction, please acknowledge the source as Courtesy of虎了吧唧