<div dir="ltr"><div>Hi Nyall,</div><div>sorry for the iface issue my bad. When I used it was to attempt to load the layer after the creation of the vector layer. <br></div><div><br></div><div>1 lesson learn - Hey iface stay away from processing :P  <br></div><div><br></div><div>Thank you for your time this small fix is now working.</div><div><br></div><div>Best regards.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> escreveu no dia quarta, 31/07/2019 à(s) 23:45:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 1 Aug 2019 at 01:30, João Gaspar <<a href="mailto:joao.f.r.gaspar@gmail.com" target="_blank">joao.f.r.gaspar@gmail.com</a>> wrote:<br>
><br>
> Hi devs<br>
> I'm trying to do a Python Script in Processing without an input layer and generate an output layer based on a number of fields that respects an order, name, type of field, precision.<br>
><br>
> The problem: I have some standard procedures that use a template shapefile. Most of the time users create a new template or truncate existing layers.<br>
><br>
> To save some clicks what I'm trying to do is create instantly the templates without user lose time. I'm using processing to get the advantage of batch mode.<br>
><br>
> This is my actual code but crashes when I run (see .py in attach)<br>
><br>
> I think the problem is in the moment of writing the output file.<br>
<br>
Ouch - never, EVER use "iface" in Processing scripts!<br>
<br>
The problem is in the line:<br>
<br>
layer = iface.addVectorLayer(self.OUTPUT, 'layer1', 'ogr')<br>
<br>
You should remove this line, and replace the return dict with the path<br>
to your created layer, e.g.:<br>
<br>
return {self.OUTPUT: '/home/me/my.shp'}<br>
<br>
Processing will automatically load this as a layer when required.<br>
<br>
Nyall<br>
<br>
<br>
<br>
><br>
> Kind regards<br>
><br>
> _______________________________________________<br>
> QGIS-Developer mailing list<br>
> <a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>