Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigRoy/97150c7c6f0a0c916418207b9a2bc8f1 to your computer and use it in GitHub Desktop.
Save BigRoy/97150c7c6f0a0c916418207b9a2bc8f1 to your computer and use it in GitHub Desktop.
Scrape the export formats labels + internal urls from the Substance Painter Export dialog
import json
from PySide2 import QtCore, QtWidgets
import substance_painter.js
def scrape_export_presets():
app = QtWidgets.QApplication.instance()
# Allow app to catch up
app.processEvents()
dialog = app.activeWindow()
assert dialog, "A window must be active now"
assert dialog.windowTitle() == "Export textures", "Export Textures dialog must be visible"
app.processEvents()
presets = {}
for box in dialog.findChildren(QtWidgets.QComboBox):
# Let's assume the box we want has both 'Sketchfab' and '2D View'
if box.findText("Sketchfab") == -1:
continue
if box.findText("2D View") == -1:
continue
model = box.model()
for y in range(model.rowCount()):
item = model.item(y)
label = item.text()
print(label)
try:
url = item.data(QtCore.Qt.UserRole + 1) # url role?
presets[url.toDisplayString()] = label
except (RuntimeError, AttributeError):
print('NO URL')
dialog.close()
data = json.dumps(presets, indent=4)
print(data)
QtCore.QTimer.singleShot(0, scrape_export_presets)
substance_painter.js.evaluate("alg.mapexport.showExportDialog()")
@BigRoy
Copy link
Author

BigRoy commented Jan 9, 2023

Example output from Substance Painter 8.2.0:

[Python] 2D View
[Python] Document channels + Normal + AO (No Alpha)
[Python] Document channels + Normal + AO (With Alpha)
[Python] Sketchfab
[Python] Substance 3D Stager
[Python] USD PBR Metal Roughness
[Python] glTF PBR Metal Roughness
[Python] glTF PBR Metal Roughness + Displacement texture (experimental)
[Python] NO URL
[Python] Amazon Lumberyard
[Python] NO URL
[Python] Arnold (AiStandard)
[Python] NO URL
[Python] Arnold UDIM Legacy (AiStandard)
[Python] NO URL
[Python] Blender (Principled BSDF)
[Python] NO URL
[Python] Corona
[Python] NO URL
[Python] CryEngine
[Python] NO URL
[Python] Dota 2
[Python] NO URL
[Python] KeyShot
[Python] NO URL
[Python] KeyShot 9+
[Python] NO URL
[Python] Lens Studio
[Python] NO URL
[Python] Maxwell (Metallic Roughness)
[Python] NO URL
[Python] Maxwell (Specular Glossiness)
[Python] NO URL
[Python] Mesh Maps
[Python] NO URL
[Python] Non-PBR Specular Glossiness
[Python] NO URL
[Python] PBR Metallic Roughness
[Python] NO URL
[Python] PBR Metallic Roughness (folders or PSD groups)
[Python] NO URL
[Python] PBR Specular Glossiness
[Python] NO URL
[Python] PBR Specular Glossiness (converted from Metallic Roughness)
[Python] NO URL
[Python] Redshift (rsMaterial)
[Python] NO URL
[Python] Renderman (pxrDisney)
[Python] NO URL
[Python] Renderman (pxrSurface)
[Python] NO URL
[Python] Roblox (MaterialVariant)
[Python] NO URL
[Python] Roblox (SurfaceAppearance)
[Python] NO URL
[Python] Shade 3D
[Python] NO URL
[Python] Spark AR Studio
[Python] NO URL
[Python] Unity HD Render Pipeline (Metallic Standard)
[Python] NO URL
[Python] Unity HD Render Pipeline (Specular)
[Python] NO URL
[Python] Unity Universal Render Pipeline (Metallic Standard)
[Python] NO URL
[Python] Unity Universal Render Pipeline (Specular)
[Python] NO URL
[Python] Unreal Engine 4 (Packed)
[Python] NO URL
[Python] Unreal Engine 4 SSS (Packed)
[Python] NO URL
[Python] Vray Next (Metallic Roughness)
[Python] NO URL
[Python] Vray Next (Specular Glossiness)
[Python] NO URL
[Python] Vray Next UDIM Legacy (Metallic Roughness)
[Python] NO URL

Substance Painter export-preset-generator entries

And that makes the export preset generator entries like this from URL to label.

{
    "export-preset-generator://viewport2d": "2D View",
    "export-preset-generator://doc-channel-normal-no-alpha": "Document channels + Normal + AO (No Alpha)",
    "export-preset-generator://doc-channel-normal-with-alpha": "Document channels + Normal + AO (With Alpha)",
    "export-preset-generator://sketchfab": "Sketchfab",
    "export-preset-generator://adobe-standard-material": "Substance 3D Stager",
    "export-preset-generator://usd": "USD PBR Metal Roughness",
    "export-preset-generator://gltf": "glTF PBR Metal Roughness",
    "export-preset-generator://gltf-displacement": "glTF PBR Metal Roughness + Displacement texture (experimental)"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment