fork download
  1. import bpy
  2. import pathlib
  3.  
  4.  
  5. def f():
  6. destfolder = pathlib.Path("C:\\Users\\username\\Desktop")
  7. if not destfolder.exists():
  8. raise Exception("ディレクトリが見つからない。.\n%s" % destfolder)
  9.  
  10. sce = bpy.data.scenes['Scene']
  11. for ob in sce.objects:
  12. bpy.ops.object.select_pattern(pattern=ob.name)
  13. file_name = pathlib.Path(ob.name).with_suffix(".obj")
  14. file_path = destfolder.joinpath(file_name)
  15. bpy.ops.export_scene.obj(filepath=str(file_path), use_selection=True)
  16.  
  17.  
  18. try:
  19. f()
  20. except:
  21. import traceback
  22. import sys
  23. traceback.print_exc()
  24. ei = sys.exc_info()
  25.  
  26. def draw(self, context):
  27. layout = self.layout
  28. for i in str(ei[1]).split("\n"):
  29. row = layout.row()
  30. row.label(text=i)
  31. bpy.context.window_manager.popup_menu(draw, title="Error", icon="ERROR")
  32.  
Runtime error #stdin #stdout #stderr 0.12s 23668KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ModuleNotFoundError: No module named 'bpy'