[QGIS-Developer] Add algorithm to an existing provider?

Benjamin Jakimow benjamin.jakimow at geo.hu-berlin.de
Fri May 13 00:07:09 PDT 2022


Hi Raymond,

you need to ensure that your provider saves a python reference on your 
TestAlgorithm2() (which you probably already do).
After its set of algorithms has changed (i.e. refresh, addAlgorithm(s) 
etc.) it needs to emit the algorithmsLoaded signal.

Greetings,
Benjamin

On 2022-05-13 08:15, Raymond Nijssen via QGIS-Developer wrote:
> Is there a way to add a processing algorithm to an existing provider
> using pyqgis?
> 
> I have 2 plugins and don't know if they are both installed (or which
> one will load first). The both contain processing algorithms and I
> want those to end up in the same group.
> 
> Documentation is a bit brief on this:
> 
> QgsProcessingProvider
> 
> Examples show to put the addAlgorithm() function(s) in the
> loadAlgorithms() function. Then calling
> 
> QgsApplication.processingRegistry().addProvider(provider)
> 
> adds the group (=provider?) and the algorithms are in it.
> 
> 
> 
> What I want to do is finding the provider if it exists already:
> 
> self.provider = 
> QgsApplication.processingRegistry().providerById('test')
> if self.provider is None:
>     self.provider = RayProvider()
> 
> and then:
> 
> self.provider.addAlgorithm(TestAlgorithm2())
> 
> This doesn't work, neither when doing:
> 
> provider.refreshAlgorithms()
> provider.load()
> provider.loadAlgorithms()
> ...
> 
> 
> I'm currently trial-and-errorring my way through this, but I hope
> someone has a hint. Even someone pointing at 2 plugins working like
> this would be very welcome!
> 
> Kind regards,
> Raymond
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

-- 
--
Benjamin Jakimow, Doctoral Researcher
Earth Observation Lab | Geography Department | Humboldt-Universität zu 
Berlin

e-mail: benjamin.jakimow at geo.hu-berlin.de

phone:  +49 (0) 30 2093 6894
mobile: +49 (0) 157 5656 8477
fax:    +49 (0) 30 2093 6848
mail:   Unter den Linden 6 | 10099 Berlin | Germany
room: 2'222


More information about the QGIS-Developer mailing list