Author Topic: get/setProjectExportPreset question  (Read 149 times)

We have a set of custom presets that live in export-presets in a custom directory, that is loaded with a project as the default shelf location.

When I query the current export preset using alg.mapexport.getProjectExportPreset() on a just open project the return string is this: 'resource://cur_proj/preset_01?version=15745598413335016013.spexp'

Feeding this exact string back into setProjectExportPreset() is fine. However when I try to manually give the path to this preset, without the version flag:

alg.mapexport.setProjectExportPreset('resource://cur_proj/preset_01.spexp')

Painter coughs up a file not found error:

Exception ExportError: Preset 'resource://cur_proj/preset_01.spexp' not found (qrc:/js/mapexport.js line 24)

Any pointers?

Ill post what feels like a hack solve here for future reference. I call it hacky, because I think this .spexp is already loaded in a shelf, somewhere, which I assume I should be able to find but can't. This is just adding the resource to a temp shelf? so I can get that URL and use it.

            // get the usages
            var usages = alg.resources.allowedUsages(export_settings_path)
            // import the resource inside the project
            var project_preset_path = alg.resources.importProjectResource(export_settings_path, usages[0])


where export_settings_path is the path on disk to the export settings. What I think this does is directly import the .spexp file into a temp script shelf? I then capture the temp project resource string in project_preset_path and use that in my exportDocumentMaps() call.

I am only a couple of days into my substance scripting adventure, so if I'm doing this totally wrong please jump in and school me.