Author Topic: Assigning variables to export textures output template [JS]  (Read 587 times)

Greetings and well met,
I'm trying to add a variable similar to `$mesh` and `$textureSet`. I can't find in the documentation a way to add to the output template.

Anyone have any success in this?

I'm grabbing the current selected layer and i'd like to append that to the output maps available variables. I'm not sure the repo etiquette but I do have a repo grabbing the selected layer.

Cheers
Last Edit: October 20, 2020, 05:36:18 am

Hi,

If i understand correctly you want to specify a new keyword for our export template from the scripting API. If so, this is not possible.

Can you give me details on your use case to see if i can propose an alternative ?

Can you also tell me which scripting API you are using ? JS or Python ?

Thx !
Senior Software Engineer
Substance Painter Team
@achassany

Hey Alexandre!

Thank you for the response. Yes, i'd like to pass the `$selectedLayer` into the export options so when I export I can append that to the exported file names. I'll create a imgur picture to show you what I'm intending to do. I've got a repo with the ability to have the selected layer which I can put here. I'm using JS but it seems like this notion can be achieved in python though I cannot corroborate this. https://imgur.com/a/C1Cl2MG <- imgur link of what i'd like to do in the exports.

I used the javascript plugin skeleton: https://github.com/mattattaq/substance_painter_layer_append_on_export/blob/main/main.qml#L78-L128
Last Edit: October 26, 2020, 03:21:04 am

Thanks for the details,

Just to make sure i understand properly. Do you want to export only the content of the selected layer ? Or the whole textureSet ?

Because the hook you use onExportAboutToStart() is called with the textures that are going to be exported from the export dialog. And from this dialog we can't export a single layer, we only export maps that come from the composited layer stack (and textureSet mesh maps).

Thx
Senior Software Engineer
Substance Painter Team
@achassany

I'd like to grab the string that is the selectedLayer's name so when I export I can append that string to the file name so as to make my exports a bit more specific in my naming convention so I don't have to update the names after exporting effectively adding a few seconds to my flow each export.

I've traversed the layers and i'm able to grab the string shown in this github link:
https://github.com/mattattaq/substance_painter_layer_append_on_export/blob/66baef5ed3a4245a4a980b14e4191902736f2732/main.qml#L78-L112

Thank you for your reply,
Cheers
Matthew

Hey Alexandre Chassany,

I just wanted to follow up again to see if you had any more clarity on this issue.

Cheers,
Matt

Sorry for the delay it was a busy week :/.
So if i understood correctly, what i would try to do is use the other signal "onExportFinished()" and rename the exported files adding the name of the selected layer.
In onExportFinished(), for each stack exported, get the name of the selected layer (like you do in onExportAboutToStart()), transform the file paths of the exported maps to add the name of the layer, then use the  alg. subprocess module to call the external tool of your platform to move files (MOVE on windows and mv on unix).

Cheers
Alex
Senior Software Engineer
Substance Painter Team
@achassany

No problem Alexandre,
I appreciate the response! The thing i'm unclear on is how to transform the file paths. Is there is a link in the documentation you should share that would illuminate that? Either that or if you know of a better way to relay that info i'm game.

Thanks again for the response,
Cheers
Matthew
Last Edit: November 16, 2020, 06:58:19 pm

Sorry for the delay it was a busy week :/.
So if i understood correctly, what i would try to do is use the other signal "onExportFinished()" and rename the exported files adding the name of the selected layer.
In onExportFinished(), for each stack exported, get the name of the selected layer (like you do in onExportAboutToStart()), transform the file paths of the exported maps to add the name of the layer, then use the  alg. subprocess module to call the external tool of your platform to move files (MOVE on windows and mv on unix).

Cheers
Alex

hope your holidays were pleasant Alexandre, I was hoping to reach out again on the documentation on the subprocess module to call the external tool of my platform to move files.

Cheers,
mattatttaq