5

I created a model in QGIS 3.6 with three inputs parameters (two vector layer and one vector field). When I run the model, the inputs are not sorted in a correct way: the vector field is requested before the vector layer.

For this simple example, it doesn't matter, however for more complex models with severals inputs, I fear the user could feel not confortable.

Is it possible to choose the order of the inputs parameters ?

Here are two screenshot. "Conduite" = pipe in french "regard" = manhole in french

I want the user to select firstly "regard" layer, then "ID_regard" field within "regard" layer.

enter image description here

enter image description here

4
  • Could you provide a screenshot of the model?
    – Erik
    Commented May 15, 2019 at 12:04
  • Hi Erik, I added two screenshots. I hope it would help. Commented May 16, 2019 at 10:20
  • I have the same issue with a model i'm developing. It would be great to know how to order inputs in the preferred way! Commented May 21, 2019 at 9:14
  • Iasked a similar question and there is an answer provided by @AWGIS that allows you to keep using the modeler interface (rather than exporting to Python). In brief name your inputs 00_whatever, 01_whatever, etc... and you can rename them later. gis.stackexchange.com/questions/326976/… Commented Jun 27, 2019 at 13:52

1 Answer 1

4

If you right-click your model and select the Export Model as Python Algorithm, you would get a translated script of your model. Here you could order the parameters however you like in the initAlgorithm() function. E.g.:

def initAlgorithm(self, config=None):
    self.addParameter(QgsProcessingParameterFeatureSource('1conduites', '1_Conduites', types=[QgsProcessing.TypeVectorLine], defaultValue=None))
    self.addParameter(QgsProcessingParameterVectorLayer('2regard', '2_Regard', types=[QgsProcessing.TypeVectorPoint], defaultValue=None))
    self.addParameter(QgsProcessingParameterFeatureSource('3idregard', '3_ID_regard', types=[QgsProcessing.TypeVector], defaultValue=None)) 
    self.addParameter(QgsProcessingParameterFeatureSink('Result', 'result', type=QgsProcessing.TypeVectorPolygon, createByDefault=True, defaultValue=None))

Then save and run your script which should list the parameters in the same order as in the script. This method means you need to run the script version instead of the model version but the interface is exactly the same.

3
  • Many thanks Joseph. Would it be possible to ask a feature request to choose order directly in model? Commented May 21, 2019 at 14:00
  • @MaximeRiou - Most welcome! You can ask this as a feature request.
    – Joseph
    Commented May 21, 2019 at 14:09
  • 1
    I created here issues.qgis.org/issues/22121 Commented May 24, 2019 at 21:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.