Author Topic: retrieving list of export presets ?  (Read 1651 times)

Hi ! I am trying to utilize the exportDocumentMaps function so I can export textures all at once at desired resolution.. there is only one thing that I'd like to add which is a list of export presets so I can hook it up with the function that I have.

I tried to use the alg.resources.findResources() but it seems like I can't get the export presets available in the program..does anybody know if there is any command for this / any way to get around it ? (subprocess for example ? and if yes, can I get further explanation on it since I am pretty new to scripting.)

Thank you ! :)

I can't seem to find a method for doing that personally.

Technically speaking, I'm not sure if Alg considers the Export Preset a "resource"
If you look at the results of the entire resource query using a wildcard, you'll notice there are no export presets present.

Code: [Select]
var allResources = alg.resources.findResources("allegorithmic", '*')

Unfortunately, it is not possible to get the export presets list right now.

I needed this same functionality, and came up with a way to hack it by listing the files in the shelf paths. The code below assumes all your shelf directories have an "export-presets" subdirectory.

Code: [Select]
let export_presets = [];
for (const [shelf_name, shelf_path] of Object.entries(alg.resources.shelves())) {"Searching " + shelf_name + "...");

    // Get the list of files in the export-presets subdirectory in the shelf path.
    const files = alg.fileIO.listDir(shelf_path + "/export-presets");

    // Filter out files with an spexp extension and add the file name.
    for (const f of files) {
        const comps = f.split(".");
        const ext = comps.slice(-1)[0];
        if (ext == "spexp") {
            export_presets.push(comps.slice(0, -1));
}"Export Preset Names: " + export_presets);