import bpy
import pathlib
def f():
destfolder = pathlib.Path("C:\\Users\\username\\Desktop")
if not destfolder.exists():
raise Exception("ディレクトリが見つからない。.\n%s" % destfolder)
sce = bpy.data.scenes['Scene']
for ob in sce.objects:
bpy.ops.object.select_pattern(pattern=ob.name)
file_name = pathlib.Path(ob.name).with_suffix(".obj")
file_path = destfolder.joinpath(file_name)
bpy.ops.export_scene.obj(filepath=str(file_path), use_selection=True)
try:
f()
except:
import traceback
import sys
traceback.print_exc()
ei = sys.exc_info()
def draw(self, context):
layout = self.layout
for i in str(ei[1]).split("\n"):
row = layout.row()
row.label(text=i)
bpy.context.window_manager.popup_menu(draw, title="Error", icon="ERROR")
aW1wb3J0IGJweQppbXBvcnQgcGF0aGxpYgoKCmRlZiBmKCk6CiAgICBkZXN0Zm9sZGVyID0gcGF0aGxpYi5QYXRoKCJDOlxcVXNlcnNcXHVzZXJuYW1lXFxEZXNrdG9wIikKICAgIGlmIG5vdCBkZXN0Zm9sZGVyLmV4aXN0cygpOgogICAgICAgIHJhaXNlIEV4Y2VwdGlvbigi44OH44Kj44Os44Kv44OI44Oq44GM6KaL44Gk44GL44KJ44Gq44GE44CCLlxuJXMiICUgZGVzdGZvbGRlcikKCiAgICBzY2UgPSBicHkuZGF0YS5zY2VuZXNbJ1NjZW5lJ10KICAgIGZvciBvYiBpbiBzY2Uub2JqZWN0czoKICAgICAgICBicHkub3BzLm9iamVjdC5zZWxlY3RfcGF0dGVybihwYXR0ZXJuPW9iLm5hbWUpCiAgICAgICAgZmlsZV9uYW1lID0gcGF0aGxpYi5QYXRoKG9iLm5hbWUpLndpdGhfc3VmZml4KCIub2JqIikKICAgICAgICBmaWxlX3BhdGggPSBkZXN0Zm9sZGVyLmpvaW5wYXRoKGZpbGVfbmFtZSkKICAgICAgICBicHkub3BzLmV4cG9ydF9zY2VuZS5vYmooZmlsZXBhdGg9c3RyKGZpbGVfcGF0aCksIHVzZV9zZWxlY3Rpb249VHJ1ZSkKCgp0cnk6CiAgICBmKC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