[Qgis-user] QGIS 3.0 Processing Script

Nyall Dawson nyall.dawson at gmail.com
Wed Jun 27 17:17:15 PDT 2018


On Thu, 28 Jun 2018 at 01:07, Shawn Carter <shawn.m.carter at gmail.com> wrote:
>
> My QGIS 2.x script dialogue box had two entries, one for the beginning date-time of the model run and another for entering the ending-time.  Trying to grok the new 3.x method of processing scripts, it seems like I'll have to create a dialogue box entry in the initAlgorithm() function for every single file I want loaded onto my map document.  Then I have to pipe each QgsRasterLayer and QgsVectorLayer into a feature sink? Is that correct or is there a method of simply loading the files?

That doesn't sound right, but it's impossible to tell without seeing
your script. Can you share?

>
> QgsProject.instance().addMapLayers([xxx,xxx.xxx]) does nothing when the script I'm working on runs.

Don't *ever* do this from an algorithm, unless your algorithm returns
the FlagNoThreading flag. It's not safe to manipulate project layers
from background threads. The correct way to do this is to via
context.addLayerToLoadOnCompletion, which operates AFTER your
algorithm completes, and from the main thread.

> The only thing I've managed to load so far is a vector file, but only by feeding each feature of the vector into QgsFeatureSink.  That's fine for classroom vectors, but when you start dealing with millions of polylines or points, that seems like an additional slow down.

Again, sounds wrong, but would need to see your script to confirm.

> Of all the good that QGIS 3 brings OSGEO, this seems like a really big step back into user friendliness and clean code. Although, if I'm completely off base, I will gladly take that back.

*puts fingers in ears* Incorrect. It's actually awesome. Lalalala.
*removes fingers from ears*

Nyall



More information about the Qgis-user mailing list