Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Substance Painter 10.1 (workaround new substance painter API bug) #15

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion client/ayon_substancepainter/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ def get_export_templates(config, format="png", strip_folder=True):
folder = config["exportPath"].replace("\\", "/")
preset = config["defaultExportPreset"]
cmd = f'alg.mapexport.getPathsExportDocumentMaps("{preset}", "{folder}", "{format}")' # noqa

# The optional stack path argument is broken in Substance Painter 10.1
# and fails on painter's C++ API triggering from the javascript API through
# python. So we pass it the empty list of stack paths explicitly.
# See `ayon-substancepainter` issue #13
version_info = substance_painter.application.version_info()
if version_info[0:2] >= (10, 1):
cmd = f'alg.mapexport.getPathsExportDocumentMaps("{preset}", "{folder}", "{format}", [])' # noqa

result = substance_painter.js.evaluate(cmd)

if strip_folder:
Expand Down Expand Up @@ -410,7 +419,7 @@ def get_parsed_export_maps(config):
# Get current project mesh path and project path to explicitly match
# the $mesh and $project tokens
project_mesh_path = substance_painter.project.last_imported_mesh_path()
project_path = substance_painter.project.file_path()
project_path = substance_painter.project.file_path() or ""

# Get the current export path to strip this of the beginning of filepath
# results, since filename templates don't have these we'll match without
Expand Down