Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

python access to output templates in texture export window

New Here ,
Jun 03, 2022 Jun 03, 2022

Is there access to the list of preset output templates available to the Export textures window via python API?

I have tried 

substance_painter.resource.search('u:export')

and 

substance_painter.resource.search('u:EXPORT')

to no avail. Further, this snippet:
 

    resources=substance_painter.resource.search('')

    for resource in resources:
        substance_painter.logging.log(
            substance_painter.logging.INFO, 
            'testing',
            'resource is %s' % resource.identifier().name
            )

  

never prints any of the export presets to the log. Should I expect to see i.e. 'CryEngine' in the log with the above code?

 

Ultimately, our goal is to hide from the user any export defaults we don't think are necessary for studio work. We would like to do that without removing the painter installation path from the list of available resources if at all possible. 

 

Thanks,

Chris

TOPICS
Import & Export , Scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 12, 2022 Sep 12, 2022

any solutions for this? i would also like to query the output templates already existing in the project

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 09, 2023 Jan 09, 2023

Would like to +1 and bump this question. I'm also stuck getting these through `substance_painter.resource`.

 

The documentation does seem to be able to use it as a resource for Exporting using a default preset

None of these seem to return the export presets:

resources = substance_painter.resource.search(substance_painter.resource.StandardQuery.ALL_RESOURCES)
resources = substance_painter.resource.search("")

 

And like in the original topic message I expected this to only return resources with "Usage" 'export':

substance_painter.resource.search('u:export')

 

I basically want the same list as is shown in the UI:

Colorbleed_0-1673276588918.png

preferably including the export-preset-generator variants too (above the divider) here.

Colorbleed_1-1673276624028.png

 

I'm at least able to find the currently set project template using this:

substance_painter.js.evaluate("alg.mapexport.getProjectExportPreset()")

 Which will return something like:

'export-preset-generator://doc-channel-normal-no-alpha'
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 24, 2023 Apr 24, 2023

Just checking in whether there's been any updates to Substance Painter in its API solving this? Or maybe someone figured out a decent way to do this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 24, 2023 Apr 24, 2023

Hi everyone,

 

and thanks @ChrisBurrowsCG for the question.

 

The output template files being available in your folders under:

C:\Program Files\Adobe\Adobe Substance 3D Painter\resources\starter_assets\export-presets

You should be able to use them from there.

 

With that being said, you might find another solution in our scripting documentation (help>scripting documentation>Python API>Substance_Painter package>resource module).

 

Best regards,

 

Cyril Dellenbach (Micro) | QA Support Artist | Adobe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2023 May 12, 2023

Thank you Cyril for the reply. 

 

My specific use case involves wanting to hide the contents of starter_assets/export-presets from the user without explicitly removing/moving the files on disk. For production reasons we're still working with version 7.x; when we can start working with 8.x I'll try the python resource module again. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 04, 2023 Oct 04, 2023

Not a direct approach, but you can do something like this:

import substance_painter.resource

for shelf in substance_painter.resource.Shelves.all():
    export_presets_dir = f"{shelf.path()}/export-presets"
    if not os.path.isdir(export_presets_dir):
        continue
    for filename in os.listdir(export_presets_dir):
        if not filename.endswith(".spexp"):
            continue
        name = os.path.splitext(filename)[0]
        export_preset_id = substance_painter.resource.ResourceID(context=shelf.name(), name=name)
        export_preset = substance_painter.resource.Resource.retrieve(export_preset_id)[0]
        print(export_preset.gui_name())
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 05, 2023 Oct 05, 2023

Only issue here is that this doesn't return the internal preset names, right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 05, 2023 Oct 05, 2023
LATEST

It returned these names:

Amazon Lumberyard

Arnold (AiStandard)

Arnold UDIM Legacy (AiStandard)

Blender (Principled BSDF)

Corona

CryEngine

Dota 2

KeyShot 9+

KeyShot

Lens Studio

Maxwell (Metallic Roughness)

Maxwell (Specular Glossiness)

Mesh Maps

Non-PBR Specular Glossiness

PBR Metallic Roughness (folders or PSD groups)

PBR Metallic Roughness

PBR Specular Glossiness (converted from Metallic Roughness)

PBR Specular Glossiness

Redshift (rsMaterial)

Renderman (pxrDisney)

Renderman (pxrSurface)

Roblox (MaterialVariant)

Roblox (SurfaceAppearance)

Shade 3D

Spark AR Studio

Unity HD Render Pipeline (Metallic Standard)

Unity HD Render Pipeline (Specular)

Unity Universal Render Pipeline (Metallic Standard)

Unity Universal Render Pipeline (Specular)

Unreal Engine 4 (Packed)

Unreal Engine 4 SSS (Packed)

Vray Next (Metallic Roughness)

Vray Next (Specular Glossiness)

Vray Next UDIM Legacy (Metallic Roughness)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines