Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - bsilvaLS

Pages: [1] 2
1
Hello!

I'm using the Python API to export textures with a config dictionary as described in the docs. It works as expected until I add uvTiles to the filters in the exportList. The export outputs the maps for the first texture set in the list, and then silently just stops.

If I remove the uvTiles entry from the filter dicts, all the maps export as expected.

This is the config dict I'm using. All I get are the maps for textureSetA. Are there any issues I haven't spotted with the format?

(I'm on v6.2.1 on Windows 10.)

Thanks!

Code: [Select]
{'defaultExportPreset': 'resource://allegorithmic/PBR Metallic Roughness',
 'exportList': [{'filter': {'outputMaps': ['$mesh_$textureSet_BaseColor(.$udim)',
                                           '$mesh_$textureSet_Roughness(.$udim)',
                                           '$mesh_$textureSet_Metallic(.$udim)',
                                           '$mesh_$textureSet_Normal(.$udim)',
                                           '$mesh_$textureSet_Height(.$udim)',
                                           '$mesh_$textureSet_Emissive(.$udim)'],
                            'uvTiles': [[0, 1]]},
                 'rootPath': 'textureSetA'},
                {'filter': {'outputMaps': ['$mesh_$textureSet_BaseColor(.$udim)',
                                           '$mesh_$textureSet_Roughness(.$udim)',
                                           '$mesh_$textureSet_Metallic(.$udim)',
                                           '$mesh_$textureSet_Normal(.$udim)',
                                           '$mesh_$textureSet_Height(.$udim)',
                                           '$mesh_$textureSet_Emissive(.$udim)'],
                            'uvTiles': [[0, 0]]},
                 'rootPath': 'textureSetB'},
                {'filter': {'outputMaps': ['$mesh_$textureSet_BaseColor(.$udim)',
                                           '$mesh_$textureSet_Roughness(.$udim)',
                                           '$mesh_$textureSet_Metallic(.$udim)',
                                           '$mesh_$textureSet_Normal(.$udim)',
                                           '$mesh_$textureSet_Height(.$udim)',
                                           '$mesh_$textureSet_Emissive(.$udim)'],
                            'uvTiles': [[1, 0]]},
                 'rootPath': 'textureSetC'},
                {'filter': {'outputMaps': ['$mesh_$textureSet_BaseColor(.$udim)',
                                           '$mesh_$textureSet_Roughness(.$udim)',
                                           '$mesh_$textureSet_Metallic(.$udim)',
                                           '$mesh_$textureSet_Normal(.$udim)',
                                           '$mesh_$textureSet_Height(.$udim)',
                                           '$mesh_$textureSet_Emissive(.$udim)'],
                            'uvTiles': [[0, 1], [0, 3]]},
                 'rootPath': 'textureSetD'}],
 'exportParameters': [{'parameters': {'bitDepth': '8',
                                      'dithering': False,
                                      'fileFormat': 'png',
                                      'paddingAlgorithm': 'infinite',
                                      'sizeLog2': 9}}],
 'exportPath': '/some/directory/for/textures',
 'exportPresets': [],
 'exportShaderParams': True}

and then simply calling with:

Code: [Select]
result = substance_painter.export.export_project_textures(config)

2
Thanks for the workaround, Fabrice -- I'm going to give this a go shortly.

As a TD, managing export presets as JSON files would be great, since then they'd be textual. But, there are two other things I'd request to make that more useful:

  • Make it possible to export JSON from the presets editor UI. The UI makes it much faster (and less prone to error) than crafting JSON presets by hand. And, even if we manage our standard pipeline presets in JSON, it's likely we'll still want to give artists the ability to tweak these (particularly for adding bespoke channels in special cases). And artists don't typically like to edit JSON files.  ;)
  • Load up JSON presets into the editor UI, and the export dialog. Currently to make use of JSON presets, it appears it would have to be through an entirely bespoke UI (correct me if I'm wrong).

3
As a suggestion, it would be much more useful if the TextureExportResult class passed in to ExportTexturesAboutToStart/ExportTexturesEnded had a json_config dict with all the values setup according to what the export was going to do (and did), including all overrides. Also, including both the expression ("$textureSet_color") and resolved filename for each channel.

This would allow us to still use the export dialog (which is a great UI) and also do some meaningful post-processing.

It would also be extremely useful to be able to query the project for a json_config dict that represented the current saved Export Settings (like when you press Save Settings on the export dialog).

4
Ah yes, those are workfing for me now, thank you. However, I still can't seem to get nearly enough information about what was exported. As far as I can tell, all I get is the list of files, and I need all the information about the maps.

The TextureSet/Stack/Channel classes provide all the information I need, and I know I can query those on the state of the project. But those can all be overridden in the export dialog, and I don't see a way to get those values. Is this possible?

5
I'd like the option to raise the Export Textures dialog from the Python API, with some information pre-filled. Is this possible? I know it was possible in JS with alg.mapexport.showExportDialog but I need to do it from Python.

Also, in the export dialog, there is the "Save settings" button, which must put the current settings and overrides somewhere in the project. Is there a way to access these via the Python API? I'd really like to use them as a starting point for a custom export.

Thanks!

6
Hello! I don't know if they exist anywhere online, but you can get at the new Painter Python docs from the menu in Painter at Help -> Documentation -> Python API.

We're in the same boat on copying around JS plug-ins. If you look here, there is a way to specify a plug-in path for Python plug-ins in the environment (wahoo!) with the SUBSTANCE_PAINTER_PLUGINS_PATH variable.
Quote
Substance Painter/resources/python-doc/plugins/substance_painter_plugins.html

Do have a look at the substance_painter package docs though -- it doesn't yet support everything available in JS.

7
Substance PainterSubstance Painter - Scripting - Python Events for Export?
 on: April 30, 2020, 10:55:21 pm 
I noticed the events supported by the Python API don't include onExport*, like you have in the QML/JS API. Is there a plan to support those (and more) in the future?

8
Hey! First let me also express thanks for releasing the Python API! It's very exciting and will be hugely helpful. And you're already on Python 3, so thanks for pushing that forward. :)

I'm wondering a couple things about the substance_painter.export.export_project_textures method, specifically.

First, is there any way to access the settings saved by the new "Save Settings" button in the export dialog? I'd like to be able to call the export from Python, but by default have it use whatever the user saved there last. I suppose this could also be some way to get the equivalent of the exportList and exportParameters objects in the JSON -- is that possible?

Secondly, does the defaultExportPreset need to be defined in the exportPresets JSON object, or can it be the name of a preset loaded from an .spexp file?


9
Thanks Fabrice, it was totally my bad... I had a call to alg.settings instead of alg.project.settings, plus some issues with property bindings (I'm still learning QML).

I just did a little test, and you're right -- it can be called from any of my window modules.

Sorry about that, thanks!

10
One other consideration -- you could have your plug-in run steps 1, 3, 4 in response to a toolbar button, or when the application starts (through a callback in your plug-in).

But I'd also like to know -- is it possible to run Substance Painter in batch mode, i.e. without raising the UI?

11
I haven't done it before, but I believe you could sequence 1, 3, and 4 without any manual input. But as Fabrice verified, step #2 isn't possible.

12
Hello! (Links below are relative to your install directory)

1. Yes, this can be done. [.../resources/javascript-doc/alg.project.html#.create__anchor]

2. You can get information about smart materials in your layers, but I don't think it's possible to edit them... can someone from Allegorithmic verify this? This is all I'm aware of: [.../resources/javascript-doc/alg.texturesets.html#.structure__anchor]

3. This is possible, though maybe not easily. There is an update method in the API, but I'm suspecting you'd want something more automatic: [.../resources/javascript-doc/alg.resources.html#.updateDocumentResources__anchor]. The good news is, the source code for the entire Resource Updater plug-in is fully available under your plug-ins folder, so you could tweak it or pull things out of it to roll your own.

4. Yes, this is supported. [.../resources/javascript-doc/alg.mapexport.html#.exportDocumentMaps__anchor]

Cheers,

 -- B --

13
Perusing through the existing plug-ins I have (including dcc-live-link), I noticed the only calls I see to alg.project.settings are all in the main.qml file. Is this a requirement? Currently I'm calling it from a QML module window.

14
Hello! I'm working on a plug-in, and having some trouble getting project settings to persist. I'm still looking for issues in my code, but I also want to make sure I understand this correctly --

From within my plug-in, if I use the standard:
Code: [Select]
alg.project.settings.setValue("someKey", "VALUE")
then if I save the project, close and re-open Substance Painter, re-open the project, and have my plug-in call:
Code: [Select]
alg.project.settings.value("someKey")
I should get "VALUE" back, correct? Because the setting is baked into the spp file, correct?

I'm getting an undefined value right now.

Any info much appreciated!

15
Hello! I pulled in the plug-in skeleton, and am doing a bit of post-processing in the onExportFinished callback using the subprocess module. I'd like to show regular progress, ideally with an AlgProgressBar.

But, it seems like the callback itself is blocking -- even if I just do simple alg.log calls, they don't show up until the entire function is finished.

Is this expected? Is there a way I can get the main window and/or one of my plug-in windows to update while processing? I'm not sure how threading is being handled under the hood.

Thanks!

Pages: [1] 2