When I create a model in the Graphical Modeler Tool I need to add layers using ‘Add File’.

When I run the script, I have to add the same files each time (Which can lead to adding numerous files). Since none of the layers change, how do I add links to specific files?

The image below shows only two layers which need to be added each time (Listed Buildings and then Building Centre Points). In my detailed script, this happens countless times.

enter image description here

  • Usually, we have one question per topic. Please concentrate on one problem, or open several topics.
    – AndreJ
    Commented Aug 8, 2017 at 13:42
  • Thanks Andre, I have reduced it down to a single question and will tackle each issue individually. Commented Aug 8, 2017 at 13:57

1 Answer 1


I think a custom script might be needed for this which allows you to set fixed layers and use these in your model without having to constantly specify them. You can create one from:

Processing Toolbox > Scripts > Tools > Create new script

And use something like the following:

##Listed_Building=output vector
##Building_Centre_Points=output vector

from qgis.core import QgsVectorLayer

listed_building_path = "path/to/listed_buildings.shp"
centre_points_path = "path/to/centre_points.shp"

Listed_Building = QgsVectorLayer(listed_building_path, 'listed_buildings', 'ogr')
Building_Centre_Points = QgsVectorLayer(centre_points_path, 'centre_points', 'ogr')

Make sure the script is saved in your /.qgis2/processing/scripts/ directory. Then add the script into your model, replacing your input vector parameters.


  1. If I want to run the Fixed distance buffer tool on two specific layers, I would use the script above, add it into the model, add the buffer algorithm and specify the relevant input layer from the script (e.g. listed buildings):

    Specify parameters for listed buildings

  1. And repeat for the centre points

    Specify parameters for centre points

  1. Now when I run the model, there's no need to specify the input layers. I just have to assign the output paths:

    Running model

  • Hi Joseph, I have tried your script and added it to a simple script as a trial. Each and every time I run the script I get the following: Algorithm Test starting... Prepare algorithm: SCRIPTADDFILES_1 Running Addfiles [1/2] Parameters: Failed Error executing algorithm Addfiles invalid syntax (, line 36) See log for more details Commented Aug 9, 2017 at 9:45
  • @MathewBayley - Strange, could you edit your question to include the script you used and a screenshot of the model?
    – Joseph
    Commented Aug 9, 2017 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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