To rotate feature(s) in QGIS you need to be in editing mode, select one or more features then use 'Rotate Feature' tool present inside Advanced Digitizing Toolbar:

enter image description here

But how can we call this action from Python code to plug it somewhere in a plugin?

1 Answer 1


Use this script:

# Get all actions
actions = iface.mainWindow().findChildren(QAction)

# Check the action 
action = [x for x in actions if x.objectName()=='mActionRotateFeature'][0]

# Run the action
  • Thankyou Kadir, Also can you help me out in uising it without a vector layer maybe on a QgsRubberBand prior to creating a layer. Commented Jul 25, 2021 at 14:08
  • @GothamChess I read your other question. I have no idea. Actually, I didn't understand your problem. Commented Jul 25, 2021 at 14:33
  • Problem: This action can only be called after making a editing enabled vector layer. But what I am doing is allowing user to make as many RubberBands as required be it QgsRectangle or Polygon and afterwards making a vector layer housing all those polygons....In-between user may want to rotate the rubberbands too for that purpose right now I am manually setting the rotation of QgsRubberBands using a doublespinbox.Using this tool makes it more user friendly.But I am unable to get a handle to it for QgsRubberBands. Commented Jul 25, 2021 at 14:41
  • 1
    @Taras Thanks, you are right, I am aware of that. The user has already activated editing mode. Commented Nov 29, 2022 at 10:46
  • 1
    True! I will live my comment as a small pointer ^_^
    – Taras
    Commented Nov 29, 2022 at 10:48

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.