Skip to content

Commit

Permalink
Fix several MacOS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
passivestar committed Nov 16, 2023
1 parent 654114e commit 5f29777
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ In the addon preferences you can configure:
- Texture output folder name. Default is `textures`
- Texture Set Name Regex - Regular expression used to determine the texture set name by the texture file name. Usually the texture set name goes first and is separated from other info by the first "_". Default value is `(.+?)_`

# Known Issues
# Supported Substance Versions

- The Steam version of Painter on Window is currently unsupported. Adobe version seems to be working fine. On Mac Steam version is working well too
The addon is working with any recent version of:

- Windows CC Substance Painter
- MacOS CC Substance Painter
- MacOS Steam Substance Painter

Windows Steam version is currently unsupported
15 changes: 7 additions & 8 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

bl_info = {
'name': 'Substance Import-Export Tools',
'version': (1, 3, 10),
'version': (1, 3, 11),
'author': 'passivestar',
'blender': (4, 0, 0),
'location': '3D View N Panel',
Expand All @@ -22,11 +22,13 @@ def detect_substance_painter_path():
if current_os == 'posix':
paths.extend([
f'/Applications/Adobe Substance 3D Painter.app/Contents/MacOS/Adobe Substance 3D Painter', # macOS
f'/Applications/Adobe Substance 3D Painter/Adobe Substance 3D Painter.app/Contents/MacOS/Adobe Substance 3D Painter', # macOS
f'~/Library/Application Support/Steam/steamapps/common/Substance 3D Painter/Adobe Substance 3D Painter.app/Contents/MacOS/Adobe Substance 3D Painter' # macOS Steam
])
for year in range(2020, 2026):
paths.extend([
f'/Applications/Adobe Substance 3D Painter {year}.app/Contents/MacOS/Adobe Substance 3D Painter', # macOS
f'/Applications/Adobe Substance 3D Painter/Adobe Substance 3D Painter {year}.app/Contents/MacOS/Adobe Substance 3D Painter', # macOS
f'~/Library/Application Support/Steam/steamapps/common/Substance 3D Painter {year}/Adobe Substance 3D Painter.app/Contents/MacOS/Adobe Substance 3D Painter' # macOS Steam
])
elif current_os == 'nt':
Expand Down Expand Up @@ -168,18 +170,15 @@ def execute(self, context):
self.report({'ERROR'}, 'Substance Painter path is not valid. Please set the corrent path to Substance Painter in addon preferences')
return {'FINISHED'}

# Escape the painter path on posix
if os.name == 'posix':
painter_path = re.sub(r'(?<!\\) ', r'\ ', painter_path)
# Check if a mac .app and add the executable part automatically
if painter_path.endswith('.app'):
painter_path = painter_path + '/Contents/MacOS/Adobe Substance 3D Painter'
# Check if a mac .app and add the executable part automatically first
if os.name == 'posix' and painter_path.endswith('.app'):
painter_path = painter_path + '/Contents/MacOS/Adobe Substance 3D Painter'

try:
if os.name == 'nt':
subprocess.Popen([painter_path, '--mesh', fbx, '--export-path', textures, spp])
else:
subprocess.Popen(f'{painter_path} --mesh {fbx} --export-path {textures} {spp}', shell=True)
subprocess.Popen(f'"{painter_path}" --mesh "{fbx}" --export-path "{textures}" "{spp}"', shell=True)

except Exception as e:
self.report({'ERROR'}, f'Error opening Substance Painter: {e}')
Expand Down

0 comments on commit 5f29777

Please sign in to comment.