# How can I always run an algorithm with standard input shapefiles from mapcanvas in QGIS 2.0.1?

I created a model in the graphical modeler and I want to run that model always with two specific polygon shapefiles from my project, e.g. pst and astenot. Whenever I run my model, it asks me to set the inputs from the list of shapefiles that are in my MapCanvas. To be more specific, I always want vectorlayer_1='pst' and vectorlayer_2='astenot'.

This is the script from my model. Can anyone tell me how I can do that? I'm wondering if there is a way to do that directly in graphical modeler.

##difference_between_pst/astenot=name
##vectorlayer_1=vector
##vectorlayer_2=vector
##output_alg0=output vector
##output_alg1=output vector
##output_layer_alg2=output vector
##output_layer_alg3=output vector
outputs_0=Processing.runalg("qgis:difference", vectorlayer_1, vectorlayer_2, output_alg0)
outputs_1=Processing.runalg("qgis:difference", vectorlayer_2, vectorlayer_1, output_alg1)
outputs_2=Processing.runalg("qgis:saveselectedfeatures", outputs_0['OUTPUT'], output_layer_alg2)
outputs_3=Processing.runalg("qgis:saveselectedfeatures", outputs_1['OUTPUT'], output_layer_alg3)


Change you script in:

##difference_between_pst/astenot=name
##output_alg0=output vector
##output_alg1=output vector
##output_layer_alg2=output vector
##output_layer_alg3=output vector
vectorlayer_1 = "pst"
vectorlayer_2 = "astenot"
outputs_0=Processing.runalg("qgis:difference", vectorlayer_1, vectorlayer_2,   output_alg0)
outputs_1=Processing.runalg("qgis:difference", vectorlayer_2, vectorlayer_1,  output_alg1)
outputs_2=Processing.runalg("qgis:saveselectedfeatures", outputs_0['OUTPUT'], output_layer_alg2)
outputs_3=Processing.runalg("qgis:saveselectedfeatures", outputs_1['OUTPUT'], output_layer_alg3)


• It came up with an error :name 'Processing' is not defined. – elena Nov 28 '13 at 6:12
• In QGIS 2.0, it is processing, in QGIS master, it is Processing – gene Nov 28 '13 at 17:38
• After changing Processing with processing, another error came up : name 'vectorlayer_1' is not defined. – elena Nov 29 '13 at 6:38
• I found this :map = QgsMapCanavs() , layer = QgsVectoryLayer('path.shp','myshapefile','ogr'), map.setLayerSet([layer]), to create a script that opens a layer in a map canvas (gis.stackexchange.com/questions/29580/…). But i don't know how to use it in the code. It would be helpful if you have any idea. Thanks for your help anyway! – elena Nov 29 '13 at 8:05
• Maybe it's working only from python console and not from script editor? – elena Nov 29 '13 at 8:10