Author Topic: Export config generator  (Read 729 times)

Download: python script and sample yaml preset.

I was tired of having to manually translate all my export presets into a single .json config file (for using with the python api), so made this little tool to convert from YAML files inside a folder.

Usage: python create_export_config_file.py C:\path\to\dir
(*needs pyyaml module installed)

It will generate a file that you can use with:  substance_painter.export.export_project_textures(export_config)

YAML presets are expected to follow this format, which helps readability + shortening the files:

name: Basic Preset
maps:

  - fileName: $mesh_$textureSet_BaseColor
    channels:
     - R R documentMap baseColor
     - G G documentMap baseColor
     - B B documentMap baseColor

    parameters:
     dithering: false
     fileFormat: png
     bitDepth: 8
     paddingAlgorithm: infinite
     dilationDistance: 16

  - fileName: $mesh_$textureSet_Normal
    channels:
     - R R virtualMap Normal_OpenGL
     - G G virtualMap Normal_OpenGL
     - B B virtualMap Normal_OpenGL
     - A A virtualMap Normal_OpenGL

  - fileName: $mesh_$textureSet_Roughness
    channels:
     - L L documentMap roughness

  - fileName: $mesh_$textureSet_Metallic
    channels:
     - L L documentMap metallic


...In the above case, "parameters" will be cloned from the first block onto all other maps, but you can optionally define a block for each map repeating the same syntax.

Channel lines expect this formatting:
destChannel srcChannel srcMapType srcMapName (example: "R R documentMap baseColor")

Multiple YAML files will generate multiple presets inside a single export config file. The default preset is set to be the first yaml found on folder (or the one defined inside the .py file, if not empty).

Finally you can inspect the .py file to change a couple defaults for the config, on these lines:

# CHANGE YOUR PRESET FILE DEFAULTS HERE
#---------------------------------------
preset_file = {
   'exportPath': '',
   'exportShaderParams': False,
   'defaultExportPreset': '',
   'exportList': [],
   'exportParameters': [],
}
#---------------------------------------


Hope it helps.