[Qgis-user] QGIS 3 Processing question
Rudi von Staden
rudivs at gmail.com
Sun Jul 1 06:56:20 PDT 2018
Hi Frank,
On Fri, 29 Jun 2018 at 09:35, Frank Broniewski <hallo at frankbroniewski.com>
wrote:
> Anyway, my testing-algorithm-script is still not working. It runs through,
> but I do not get the expected result loaded into the layer tree. I suppose
> it runs through - the output from the 'qgis:pointsalonglines' is a
> QgsVectorLayer - but after finishing I get nuthink back.
>
>
I had a similar problem. I think it's because the template defines the
output as a feature sink, so you assume you have to use the same. I think
if you change your definition from:
self.addParameter(
QgsProcessingParameterFeatureSink(
self.OUTPUT,
self.tr('Center line')
)
)
to:
self.addParameter(
QgsProcessingParameterVectorDestination(
self.OUTPUT,
self.tr('Center line')
)
)
and then in processAlgorithm you need to add output as a layer you can work
with:
output = self.parameterAsOutputLayer(parameters,self.OUTPUT,context)
Finally, in your `params` dict, change the value for OUTPUT from `memory:`
to `output`.
The new syntax is more complicated than it used to be, and it takes some
time to wrap your head around it. I do find that it gets easier once you've
got a couple of scripts under your belt.
Rudi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180701/dd9a3ba6/attachment.html>
More information about the Qgis-user
mailing list