[QGIS-Developer] Trigger Add Polygon Feature and Digitize with Segment in Digitizing Toolbar Not working consistently

Catania, Luke A ERDC-RDE-GRL-VA CIV Luke.A.Catania at erdc.dren.mil
Wed Apr 9 12:51:10 PDT 2025


I have this method that triggers the tools mentioned in the subject, but only sometimes it triggers Digitize with Segment.  Other times it seems to revert to Digitize with Shape.  IDK if something after the fact is resetting it.

@classmethod
    def trigger_line_feature_digitize_with_segment(cls) -> None:
        """Triggers the Polygon Tool of the Digitizing Toolbar and Digitize with Segment.
        One current use is when user draws an AOI or LUC polygon.
        """
        for action in iface.digitizeToolBar().actions():
            if action.text() == "Add Line Feature":
                action.trigger()
                cls._log_qgis_settings_msg("Add Line Feature Triggered")
                break

        for qtoolbutton in iface.digitizeToolBar().findChildren(QToolButton):
            if qtoolbutton.menu():
                for action in qtoolbutton.menu().actions():
                    if action.text() == "Digitize with Segment":
                        action.trigger()
                        cls._log_qgis_settings_msg("Digitize with Segment Triggered")
                        break


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/20250409/88c0bd36/attachment.htm>


More information about the QGIS-Developer mailing list