Skip to content

Commit

Permalink
Update startup.py (#4)
Browse files Browse the repository at this point in the history
* Update startup.py
Now handles correctly cases in Windows platform where the Documents folder has been relocated. Thanks @aiblis for the work!
  • Loading branch information
Alfonso Casado authored and diegogarciahuerta committed Oct 27, 2019
1 parent f46fb8e commit 7021a75
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import shutil
import hashlib
import socket
##############

import sgtk
from sgtk.platform import SoftwareLauncher, SoftwareVersion, LaunchInformation
Expand All @@ -32,7 +33,6 @@ def get_file_info(filename, info):
"""
import array
from ctypes import windll, create_string_buffer, c_uint, string_at, byref

# Get size needed for buffer (0 if no info)
size = windll.version.GetFileVersionInfoSizeA(filename, None)
# If no info in file -> empty string
Expand Down Expand Up @@ -251,9 +251,23 @@ def prepare_launch(self, exec_path, args, file_to_open=None):
required_env["SGTK_CONTEXT"] = sgtk.context.serialize(self.context)

# ensure scripts are up to date on the substance painter side
user_scripts_path = (
os.path.expanduser(r"~/Documents/Allegorithmic/Substance Painter/plugins")
)

# Platform-specific plug-in paths

if sys.platform == 'win32':
import ctypes.wintypes
CSIDL_PERSONAL = 5 # My Documents
SHGFP_TYPE_CURRENT = 0 # Get current My Documents folder, not default value

path_buffer= ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, path_buffer)

user_scripts_path = path_buffer.value + r"\Allegorithmic\Substance Painter\plugins"

else:
user_scripts_path = (
os.path.expanduser(r"~/Documents/Allegorithmic/Substance Painter/plugins")
)

ensure_scripts_up_to_date(resources_plugins_path, user_scripts_path)

Expand Down

0 comments on commit 7021a75

Please sign in to comment.