4

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

  • Could you provide a screenshot of the model? – Erik May 15 '19 at 12:04
  • Hi Erik, I added two screenshots. I hope it would help. – Maxime Riou May 16 '19 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! – Giordano Rosadoni May 21 '19 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/… – Oliver Burdekin Jun 27 '19 at 13:52
3

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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