Sure
You can get the function from the processing toolbox. Here's how to use it: As per http://docs.qgis.org/2.8/en/docs/user_manual/processing/console.html
From the console you can get a list of all the algorithms available which contain the word "clip" by typing:
import processing
processing.alglist("clip")
Then you could find out how to use what appears the most appropriate function with:
processing.alghelp("qgis:clip")
Then simply use the algorithm in your script as follows:
processing.runalg("qgis:clip",inputlayer,overlaylayer,"output_file.shp")
Note: The algorithm will work only on slected features"
Note above code is invalid for 3.0+
for the alglist example you can do:
print([a.id() for a in gsApplication.processingRegistry().algorithms() if "clip" in a.id()])
for the alghelp example you can do:
processing.algorithmHelp("qgis:clip")
For QGIS3 see this question:
What is the new alglist and alghelp in QGIS 3.0 Processing?
Best Answer
BJEBN has suggested a function from the processing toolbox. Here's how to use it: As per http://qgis.org/de/docs/user_manual/processing/console.html
From the console you can get a list of all the algorithms available which contain the word "Voronoi" by typing:
Then you could find out how to use what appears the most appropriate function with:
Then simply use the algorithm in your script as follows: