[QGIS-Developer] How to get the rotation angle from the Rotate Tool in Advanced Digitizing Toolbar
Catania, Luke A ERDC-RDE-GRL-VA CIV
Luke.A.Catania at erdc.dren.mil
Tue Sep 3 18:02:18 PDT 2024
When I run the rotate tool in the Advanced Digitizing Toolbar it pops up a small window that allows you to change the snap to angle and show the angle the selected feature is rotated to. Is there a way to get access to the angle through python?
actions = iface.mainWindow().findChildren(QAction)
self.action_rotate_feature = [x for x in actions if x.objectName()=='mActionRotateFeature'][0]
self.placed_element_layer.selectAll()
# Inititates rotate feature action allowing to select a snap to value.
self.action_rotate_feature.trigger()
My problem is I call this tool on a layer where I programmatically select the features to rotate. I can see they are all rotating but when I edit my session as below only one of the features gets unrotated somehow, If I do not end the edit session as below and I allow the user to toggle editing off all the layers stay rotated until I exit QGIS and then QGIS unexpectedly ends.
if self.element_rotated:
self.placed_element_layer.commitChanges()
self.placed_element_layer.endEditCommand()
I have posted the issue about features rotating and then some getting unrotated after the edit session was programmatically ended and the solution provided did not work and after replying I have not yet heard back from the person that helped. So I though as a work around if I can get the angle from the rotate tool and run the processing tool processing.run("native:rotatefeatures") using that angle I can rotate the features in the layer using that tool.
Luke Catania
US Army ERDC-GRL
JCMS Site Planning Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240904/0eaf40e2/attachment.htm>
More information about the QGIS-Developer
mailing list