Hi German, Thanks. Yes, it works that way. Do you know why?
Regards, Gabriel El jue, 19 oct 2023 a la(s) 13:04, Germán Carrillo ( carrillo.ger...@gmail.com) escribió: > Hi Gabriel, > > Does the result change if you first create a Python variable for storing > your new layer? > I mean: > > > *referenceSource = create_scratch_reference_layer()* > *snapper = QgsGeometrySnapper(referenceSource)* > > instead of: > > *snapper = QgsGeometrySnapper(* > * referenceSource=create_scratch_reference_layer()* > *)* > > Regards, > > Germán > > > El jue, 19 oct 2023 a las 14:46, Gabriel De Luca via QGIS-Developer (< > qgis-developer@lists.osgeo.org>) escribió: > >> Hello all, >> >> I am working with the QgsGeometrySnapper pyqgis class, and have a >> problem to snap to a reference layer which is created inside a function >> (and returned by it). >> >> The code shared at [1] prints: >> >> result = <QgsGeometry: Polygon ((0.10000000000000001 >> -0.10000000000000001, 10.09999999999999964 0, 9.90000000000000036 >> 10.09999999999999964, 0 10, 0.10000000000000001 -0.10000000000000001))> >> >> Which means that the geomPolygon was not snapped to the reference layer. >> But, if uncomment the line 41, which adds the reference layer to the >> project, the code prints: >> >> result = <QgsGeometry: Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))> >> >> So, for some reason, adding the reference layer to the project makes >> the snapper to work. >> >> I want to ask you if you know why is this happening. Maybe I need to >> add something to make it work consistently. >> >> >> Regards, >> Gabriel >> >> [1] https://pastebin.com/raw/Y9v51ZMq >> _______________________________________________ >> 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 >> > > > -- > ----------- > |\__ > (:>__)( > |/ > Soluciones Geoinformáticas Libres > http://geotux.tuxfamily.org/ > https://twitter.com/GeoTux2 <http://twitter.com/GeoTux2> > > <http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo> >
_______________________________________________ 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