forked from njanakiev/openstreetmap-heatmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_script.py
30 lines (24 loc) · 820 Bytes
/
run_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import bpy
import os
import sys
import importlib
# Specify the script to be executed
scriptFile = "render_osm_data.py"
# Check if script is executed in Blender and get absolute path of current folder
if bpy.context.space_data is not None:
cwd = os.path.dirname(bpy.context.space_data.text.filepath)
else:
cwd = os.path.dirname(os.path.abspath(__file__))
# Get scripts folder and add it to the search path for modules
sys.path.append(cwd)
# Change current working directory to scripts folder
os.chdir(cwd)
# Compile and execute script file
file = os.path.join(cwd, scriptFile)
# Reload the previously imported modules
import utils, utils_osm
if 'utils' in locals():
importlib.reload(utils)
if 'utils_osm' in locals():
importlib.reload(utils_osm)
exec(compile(open(file).read(), scriptFile, 'exec'))