7

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?

9

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
action.trigger()
6
  • Thankyou Kadir, Also can you help me out in uising it without a vector layer maybe on a QgsRubberBand prior to creating a layer. Jul 25 at 14:08
  • @GothamChess I read your other question. I have no idea. Actually, I didn't understand your problem. Jul 25 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. Jul 25 at 14:41
  • Big PyQGIS Boss is now back in GIS SE town 😃
    – Taras
    Jul 27 at 6:02
  • 1
    @Taras I wouldn't call myself a boss. Many things to learn. Jul 27 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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