Hi, > As I don't have the context explaining why you need this
I try to "save" measurements as annotation or linestring/area layer in order to see measurements in layouts. Currently, I copy (linear) measurements and use the coordinates from QGuiApplication.clipboard() to draw a temporary linestring. I would like to skip copying the measurements. Also, I would like to "save" area measurements where copy is not supported by the measurement gui. Any ideas? Simon -----Ursprüngliche Nachricht----- Von: Jacky Volpes <jacky.vol...@oslandia.com> Gesendet: Freitag, 6. Oktober 2023 15:00 An: qgis-developer@lists.osgeo.org Cc: Simon Gröchenig <groeche...@zt-gis.at> Betreff: Re: [QGIS-Developer] Reading current measurement with python Hi Simon, Ok, I understand your question now. Unfortunately, the measurement tool is not accessible with the python API. As I don't have the context explaining why you need this, I can propose you to find another way for your process, or, if you really need to get the measurement value, here is a code snippet that finds the text within the measurement dialog (I don't recommend you to use this in a production environment though, or you might have unexpected behaviors if something changes in the dialog implementation). measurementDialogs = [d for d in iface.mainWindow().findChildren(QDialog, "QgsMeasureBase") if d.isVisible()] if len(measurementDialogs) == 1: measurementDialog = measurementDialogs[0] totalTextLineEdit = measurementDialog.findChild(QLineEdit, "editTotal") if totalTextLineEdit is not None: print(totalTextLineEdit.text()) Best regards, Jacky Volpes Ingénieur SIG - Oslandia -- Le 04/10/2023 à 10:15, Simon Gröchenig a écrit : > Hi Jacky, > > thanks for your help and for pointing me to this code snippet. > > However, I see that the measurement tools are instances of QgsMapTool with an > QAction (and not QgsMapToolDigitizeFeature) and therefore > mapTool().pointsZM() is not available. > > Now I wonder if I can utilize the QgsRubberBand > > Best regards > Simon > > > ------------------------------ > > Message: 2 > Date: Mon, 2 Oct 2023 08:56:58 +0200 > From: Jacky Volpes <jacky.vol...@oslandia.com> > To: qgis-developer@lists.osgeo.org > Subject: Re: [QGIS-Developer] Reading current measurement with python > Message-ID: <352a9e94-9010-4f39-8738-89323a87a...@oslandia.com> > Content-Type: text/plain; charset="utf-8"; Format="flowed" > > Hi, > > You can have a look at this snippet: > https://lists.osgeo.org/pipermail/qgis-developer/2023-May/065789.html > > Regards, > > -- > > Jacky Volpes > > Ing?nieur SIG - Oslandia > > -- > > Le 02/10/2023 ? 07:05, Simon Gr?chenig via QGIS-Developer a ?crit?: >> Hi list, >> >> is it possible to get the current line/area measurement with Python? >> >> Simon >> >> >> _______________________________________________ >> QGIS-Developer mailing list >> QGIS-Developer@lists.osgeo.org >> List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer >> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231002/ce6f1c41/attachment-0001.htm> > _______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer