1

I want to create a plugin which can draw irregular polygons in QGIS. For that, I want to call the Select features by freehand default tool inside my plugin. How can I do this within a python script?

2
  • You want to call all its functionality (i.e., draw a polygon and select features) or only to draw the polygon? Commented Feb 19, 2015 at 13:02
  • I want to draw a irregular polygon select all it's data from table and write it as a csv file.
    – Shiva
    Commented Feb 19, 2015 at 13:08

1 Answer 1

2

This should work:

iface.actionSelectFreehand().trigger()
4
  • I'm new to qgis so where i want to add this code exactly inside my .py file
    – Shiva
    Commented Feb 19, 2015 at 13:28
  • Difficult from me to say. It depends on your plugin's logic. Please see What is the purpose of some functions and files in QGIS Python plugins? to figure it out. Most of the cases you would like to put the code in the run( self ) method. You need to make sure you have stored a reference to the iface object inside the __init__( self, iface ) function. Commented Feb 19, 2015 at 13:43
  • Note that you could run the line of code from my answer directly in the QGIS Python console, but in your plugin you would call it this self.iface.actionSelectFreehand().trigger(). Commented Feb 19, 2015 at 13:44
  • @gccarrillo Sorry i dont knw about that.
    – Shiva
    Commented Mar 3, 2015 at 12:41

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.