Skip to main content
Participant
February 16, 2023
Question

Rename through python

  • February 16, 2023
  • 2 replies
  • 877 views

Hi community,

 

I need to be able to rename a texture set through the API in python.

I can't for the life of me understand why this isn't available. 

 

The $mesh variable under the output template maps uses this name when outputting textures.

 

Another alternative is to create a custom variable within the painter session, and use that for the export. Something like $myCustom = 'MyNewName'

 

A Third option is to actually write the output templates in python, but when I open one up, they are encoded so there is no way to read in the file and change some text, then save it.

 

So all my options are exhausted. Does anyone know of a solution to this?

This topic has been closed for replies.

2 replies

Participant
November 23, 2023

Hi, did you find how to change the textureset name through python API?

Participant
February 16, 2023

I did find This link which could resolve the naming, but I can't work out what

rootPath

is supposed to be. This looks like just a string. And even if I create a path with this folder in it: asset_test - painter continues to complain that asset_test is not found. May I request an example of how to use this rootPath: option?

https://community.adobe.com/t5/substance-3d-painter-discussions/export-8k-textures-via-python-api/m-p/13084532

 

 

Participant
February 17, 2023

Looking furter into this, I discover that what I need specifically is to use an existing preset, but to set a unique file path. For whatever reason, once I load a preset, I can't change it's file path. I either define a completely new preset through json, or I use an existing one, I can't proceedurally change the filepath of an existing one. 

 

Could someone please supply an example of how I would do that? 

 

Say I want to load: 

 

export_preset = substance_painter.resource.ResourceID(context="starter_assets", name="PBR Metallic Roughness")
stack = substance_painter.textureset.get_active_stack()

Then I am setting that preset but attempting to change each maps output path:

export_config = {
            "exportShaderParams": False,
            "exportPath": "W:/test/monolith/Substance/Painter_Auto_Export/",
            "defaultExportPreset": export_preset.url(),
            "exportPresets": [{
                "name": "PBR Metallic Roughness",
                "maps": [
                    {"fileName": "/Painter_Auto_Export/NewName_color(.$udim)"},
                    {"fileName": "/Painter_Auto_Export/NewName_metalness(.$udim)"},
                    {"fileName": "/Painter_Auto_Export/NewName_normal(.$udim)"}
                        ]
            }],
            "exportList": [{"rootPath": str(stack)}],
            "exportParameters": [
                {
                    "parameters": {
                        "fileFormat": "png",
                        "bitDepth": "8",
                        "dithering": True,
                        "paddingAlgorithm": "infinite"
                    }
                }]
        }

 

The result is that I get output paths that are defined by the PBR Metallic roughness preset, but I need paths that are unique to my map settings. I'm trying to override them as it were.

 

Inspiring
May 24, 2023