I am working on a python script in the processing environment of QGIS 2.18. My goal is to run few tools one after another in an automated chain.
One of these tools is the external Plugin 'Join multiple lines'. By clicking the Plugin Icon it dissolves selected lines without opening a GUI. My problem is, that I don't know how to execute the Plugin via the console. Unfortunately, suggestions like in this post did not help me.
After installing the plugin, I can import the module via the console with the following line:
from joinmultiplelines import joinmultiplelines as j
I also can access the class 'joinmultiplelines' of the plugin, where the initGui, run and other methods are included:
Now apparently, I can not just execute the run-method of the plugin like this:
j.joinmultiplelines.run() Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: unbound method run() must be called with joinmultiplelines instance as first argument (got nothing instead)
The error with the unbound method I tried to overcome by creating a class instance, without success:
classInstance = j.joinmultiplelines() Traceback (most recent call last): File "<input>", line 1, in <module> TypeError: __init__() takes exactly 2 arguments (1 given)
I feel like getting closer when I added selected features as argument:
layer = iface.activeLayer() selFeats = layer.selectedFeatures() classInstance = j.joinmultiplelines(selFeats) classInstance.run() Traceback (most recent call last): File "<input>", line 1, in <module> File "Path/to/python/plugins\joinmultiplelines\joinmultiplelines.py", line 155, in run cl = self.iface.mapCanvas().currentLayer() AttributeError: 'list' object has no attribute 'mapCanvas'
Can somebody help me with the arguments I have to use in order to run the plugin from the console, or am I underestimating the skills needed to solve it?