[QGIS-Developer] Retrieve folder path from Processing scripts

matteo matteo.ghetta at gmail.com
Mon May 28 06:23:35 PDT 2018


Hi devs,

I don't know if I'm facing a bug or if I'm missing something. In a
Processing script (or Processing plugin, same same) I cannot not get the
path of the folder when the folder is a Processing parameter:

...
NAME = 'NAME'
FOLDER = 'FOLDER'
...
self.addParameter(QgsProcessingParameterString(
        self.NAME,
        self.tr('My name')))

self.addParameter(QgsProcessingParameterFolderDestination(
        self.FOLDER,
        self.tr('Output folder')))
...
baseName = self.parameterAsString(parameters, self.NAME, context)
directory = self.parameterAsString(parameters, self.FOLDER, context)
basePath = os.path.join(directory, baseName)
feedback.pushDebugInfo(basePath)
return {self.FOLDER: basePath}


I always get a temporary path even when the user choose a folder on the
computer.

Someone else faced this problem?

Thanks for any suggestion!

Matteo


More information about the QGIS-Developer mailing list