Hi Nyall,
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.

1 lesson learn - Hey iface stay away from processing :P

Thank you for your time this small fix is now working.

Best regards.

Nyall Dawson <[email protected]> escreveu no dia quarta, 31/07/2019
à(s) 23:45:

> On Thu, 1 Aug 2019 at 01:30, João Gaspar <[email protected]>
> wrote:
> >
> > Hi devs
> > 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.
> >
> > 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.
> >
> > 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.
> >
> > This is my actual code but crashes when I run (see .py in attach)
> >
> > I think the problem is in the moment of writing the output file.
>
> Ouch - never, EVER use "iface" in Processing scripts!
>
> The problem is in the line:
>
> layer = iface.addVectorLayer(self.OUTPUT, 'layer1', 'ogr')
>
> You should remove this line, and replace the return dict with the path
> to your created layer, e.g.:
>
> return {self.OUTPUT: '/home/me/my.shp'}
>
> Processing will automatically load this as a layer when required.
>
> Nyall
>
>
>
> >
> > Kind regards
> >
> > _______________________________________________
> > QGIS-Developer mailing list
> > [email protected]
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to