[QGIS-Developer] Help with QgsProcessingParameter

Niccolò Marchi sciurusurbanus at hotmail.it
Fri Oct 16 09:24:46 PDT 2020


Hi Devs,
I’m contributing to the FUSION/LDV plugin and I have a couple of newbie questions related to the I/O parameters in Python.


1. SELECT MULTIPLE INPUTS
I’m not a Pythonist (I can read it and only make copy-paste-wise modifications). Unfortunately, there's one thing I don't understand of the logic related to the input of multiple files: there should be the way to create a .txt file with a list in case more than one is selected...but I haven't been able to make it work. You can find an example in xyz2dtm :



self.addParameter(QgsProcessingParameterMultipleLayers(self.INPUT,

                                                       self.tr('XYZ files'),

                                                       QgsProcessing.TypeFile))

and then calling:

fileList = fusionUtils.layersToFile('xyzDataFiles.txt', self, parameters, self.INPUT, context)



arguments.append(fileList)



When trying this with other files (.las, .laz), the txt file is created but it remains empty. This could be quite a big thing for users instead of working on mega files or file-by-file, but I have no idea ho to deal with it.


2. GENERAL OUTPUT NAME WITHOUT EXTENSION
There are some tools (e.g. TreeSeg) that require just a general “file name” that will be applied to many different outputs.
If I set just a simple name (e.g. "test_output") it doesn’t run the algo and returns an error such as “invalid name”.
In order to “fix” this, the user has to enter any kind of extension (i.e. "test_output.csv" and FUSION will strip it out using the basename for all the exports it provides.


Any suggestion or best practice about dealing with such cases?

Thanks in advance as usual,

Nic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20201016/e0d5d0d2/attachment.html>


More information about the QGIS-Developer mailing list