-
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathrun_script.py
More file actions
22 lines (18 loc) · 684 Bytes
/
run_script.py
File metadata and controls
22 lines (18 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import bpy
import os
import sys
# Specify the script to be executed
scriptFile = "fisher_iris_visualization.py"
# Check if script is executed in Blender and get absolute path of current folder
if bpy.context.space_data is not None:
filesDir = os.path.dirname(bpy.context.space_data.text.filepath)
else:
filesDir = os.path.dirname(os.path.abspath(__file__))
# Get scripts folder and add it to the search path for modules
cwd = os.path.join(filesDir, "scripts")
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)
exec(compile(open(file).read(), scriptFile, 'exec'))