<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="Ubuntu">Hi,<br>
      <br>
      If I understand well, it's possible that a styled layer could be
      sufficient...?<br>
      See "Description" section <a
        href="https://plugins.qgis.org/styles/5/">on this style</a>.<br>
      <a
href="https://docs.qgis.org/3.28/en/docs/user_manual/style_library/style_manager.html#importing-items">Import
        the style</a> in QGIS style manager.<br>
      <br>
      Regards,<br>
    </font>
    <pre class="moz-signature" cols="72">Jacky Volpes

Ingénieur SIG - Oslandia</pre>
    <div class="moz-cite-prefix">Le 09/10/2023 à 09:45, Simon Gröchenig
      a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:DU0P251MB067381226464536FE195B3F98ECEA@DU0P251MB0673.EURP251.PROD.OUTLOOK.COM">
      <pre class="moz-quote-pre" wrap="">Hi,

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">As I don't have the context explaining why you need this
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
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 <a class="moz-txt-link-rfc2396E" href="mailto:jacky.volpes@oslandia.com"><jacky.volpes@oslandia.com></a> 
Gesendet: Freitag, 6. Oktober 2023 15:00
An: <a class="moz-txt-link-abbreviated" href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>
Cc: Simon Gröchenig <a class="moz-txt-link-rfc2396E" href="mailto:groechenig@zt-gis.at"><groechenig@zt-gis.at></a>
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 :
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:jacky.volpes@oslandia.com"><jacky.volpes@oslandia.com></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>
Subject: Re: [QGIS-Developer] Reading current measurement with python
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:352a9e94-9010-4f39-8738-89323a87a15a@oslandia.com"><352a9e94-9010-4f39-8738-89323a87a15a@oslandia.com></a>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi,

You can have a look at this snippet:
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/pipermail/qgis-developer/2023-May/065789.html">https://lists.osgeo.org/pipermail/qgis-developer/2023-May/065789.html</a>

Regards,

--

Jacky Volpes

Ing?nieur SIG - Oslandia

--

Le 02/10/2023 ? 07:05, Simon Gr?chenig via QGIS-Developer a ?crit?:
</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">Hi list,

is it possible to get the current line/area measurement with Python?

Simon


_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List <a class="moz-txt-link-freetext" href="info:https://lists.osgeo.org/mailman/listinfo/qgis-developer">info:https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe:<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">-------------- next part --------------
An HTML attachment was scrubbed...
URL: <a class="moz-txt-link-rfc2396E" href="http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231002/ce6f1c41/attachment-0001.htm"><http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231002/ce6f1c41/attachment-0001.htm></a>

</pre>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>