-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathresize_scenery_textures.py
65 lines (53 loc) · 2.08 KB
/
resize_scenery_textures.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
#
# <pep8 compliant>
import os
import site
import sys
import bpy
CONSTANTS_FOLDER = "constants"
UTILS_FOLDER = "utils"
SCRIPT_FOLDER = "scripts"
# Check if script is executed in Blender and get absolute path of current folder
if bpy.context.space_data is not None:
sources_path = os.path.dirname(bpy.context.space_data.text.filepath)
else:
sources_path = os.path.dirname(os.path.abspath(__file__))
# Get scripts folder and add it to the search path for modules
os.chdir(sources_path)
sys.path.append(site.USER_SITE)
if sources_path not in sys.path:
sys.path.append(sources_path)
# Get scripts folder and add it to the search path for modules
cwd = os.path.join(sources_path, CONSTANTS_FOLDER)
if cwd not in sys.path:
sys.path.append(cwd)
# Get scripts folder and add it to the search path for modules
cwd = os.path.join(sources_path, UTILS_FOLDER)
if cwd not in sys.path:
sys.path.append(cwd)
# Get scripts folder and add it to the search path for modules
cwd = os.path.join(sources_path, SCRIPT_FOLDER)
if cwd not in sys.path:
sys.path.append(cwd)
from utils import *
from constants import *
# Specify the script to be included
script_files = ["resize_scenery_textures_script.py"]
for script_file in script_files:
# Compile and execute script file
exec(compile(open(os.path.join(cwd, script_file)).read(), script_file, PYTHON_COMPIL_OPTION))