<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
That would probably be the correct issue. I wrote some "working" code for the developer to have as starting basis so probably the AI as you mentioned added some garbage to it. Unfortunately, I tested it on my local machine, and it seemed to work for me but
maybe I was not paying too much attention to it. Will try as you describe and make sure to check thoroughly the docs.</div>
<div class="elementToProof" style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks for the quick reply.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Nyall Dawson <nyall.dawson@gmail.com><br>
<b>Sent:</b> Tuesday, July 8, 2025 6:06 PM<br>
<b>To:</b> Antonio Locandro <antoniolocandro@hotmail.com><br>
<b>Cc:</b> qgis-developer@lists.osgeo.org <qgis-developer@lists.osgeo.org><br>
<b>Subject:</b> Re: [QGIS-Developer] use of clone</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Wed, 9 Jul 2025 at 09:41, Antonio Locandro<br>
<antoniolocandro@hotmail.com> wrote:<br>
><br>
> True! Sorry I was just eager to get some help. The code is probably not so good, we are just learning with my dev which makes it a bit more interesting the questions. This used to work a few weeks ago maybe 2-3 weeks.<br>
><br>
> for feat in point_layer.getFeatures():<br>
> geom = feat.geometry()<br>
> if point_crs != project_crs:<br>
> geom = geom.clone()<br>
> geom.transform(transform_point_to_project)<br>
> if surface_geom.intersects(geom):<br>
> new_feat = QgsFeature(feat)<br>
> new_feat.setGeometry(geom)<br>
> provider.addFeatures([new_feat])<br>
> result['features'].append(new_feat)<br>
> result['count'] += 1<br>
<br>
This code, as it's written, would NEVER have worked. Maybe you use an<br>
AI at some stage to fix something and it broke the code?<br>
<br>
Try:<br>
<br>
for feat in point_layer.getFeatures():<br>
geom = feat.geometry()<br>
if point_crs != project_crs:<br>
# no need to clone!<br>
geom.transform(transform_point_to_project)<br>
if surface_geom.intersects(geom):<br>
new_feat = QgsFeature(feat)<br>
new_feat.setGeometry(geom)<br>
provider.addFeatures([new_feat])<br>
result['features'].append(new_feat)<br>
result['count'] += 1<br>
<br>
Or:<br>
<br>
request = QgsFeatureRequest()<br>
request.setDestinationCrs(project_crs,<br>
QgsProject.instance().transformContext())<br>
for feat in point_layer.getFeatures(request):<br>
geom = feat.geometry()<br>
# no need to transform, it's now done for us!<br>
if surface_geom.intersects(geom):<br>
new_feat = QgsFeature(feat)<br>
new_feat.setGeometry(geom)<br>
provider.addFeatures([new_feat])<br>
result['features'].append(new_feat)<br>
result['count'] += 1<br>
<br>
><br>
><br>
> Then I tried this and I get that clone() is not available<br>
><br>
> geom = QgsGeometry.fromWkt("POINT(0 0)")<br>
> try:<br>
> cloned = geom.clone()<br>
> print("clone() is available:", type(cloned))<br>
> except AttributeError:<br>
> print("clone() is NOT available on QgsGeometry")<br>
> clone() is NOT available on QgsGeometry<br>
><br>
> So we have found an alternative but still wondering what we had wrong to avoid in the future.<br>
> ________________________________<br>
> From: Nyall Dawson <nyall.dawson@gmail.com><br>
> Sent: Sunday, June 29, 2025 7:44 PM<br>
> To: Antonio Locandro <antoniolocandro@hotmail.com><br>
> Cc: qgis-developer@lists.osgeo.org <qgis-developer@lists.osgeo.org><br>
> Subject: Re: [QGIS-Developer] use of clone<br>
><br>
><br>
><br>
> On Sun, 29 Jun 2025 at 03:08, Antonio Locandro via QGIS-Developer <qgis-developer@lists.osgeo.org> wrote:<br>
> ><br>
> > Hello all!<br>
> ><br>
> > I had a script that used copy_geom = geom.clone() and worked until today that I updated QGIS.<br>
><br>
> > Any thoughts?<br>
><br>
> Yes -- "it used to work" is not useful information at all! 🤪<br>
><br>
> Describe the actual error, including exception messages if appropriate. Include sample code so that we actually have some idea of what you're talking about. And never, EVER just tell developers "it doesn't work" without providing an excessive level of detail.
😜<br>
><br>
> Nyall<br>
><br>
><br>
><br>
> > _______________________________________________<br>
> > QGIS-Developer mailing list<br>
> > QGIS-Developer@lists.osgeo.org<br>
> > List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fqgis-developer&data=05%7C02%7C%7Ceb6d0ae355d3475e0e3408ddbe7c7159%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638876163860459589%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Ft%2FcBkeyrGso1xQnDqTTCI3W3yo287SxPUICBhzsGRY%3D&reserved=0</a><br>
> > Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fqgis-developer&data=05%7C02%7C%7Ceb6d0ae355d3475e0e3408ddbe7c7159%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638876163860482370%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=VpmW9G%2B9pSMY%2BhiewpwQE70ZiBPSBzYotkIHq1wgTKU%3D&reserved=0</a><br>
</div>
</span></font></div>
</body>
</html>