external_script_stub.py 439 B

1234567891011121314
  1. # This stub runs a python script relative to the currently open
  2. # blend file, useful when editing scripts externally.
  3. import bpy
  4. import os
  5. # Use your own script name here:
  6. filename = "my_script.py"
  7. filepath = os.path.join(os.path.dirname(bpy.data.filepath), filename)
  8. global_namespace = {"__file__": filepath, "__name__": "__main__"}
  9. with open(filepath, 'rb') as file:
  10. exec(compile(file.read(), filepath, 'exec'), global_namespace)