I am building a plugin in QGIS 2.14 that takes a selection of lines and creates one followong the path of those lines already selected.

My issue is that the traditional selection does not respect the order we selected the features. I saw one topic talking on this here : Get features in order they are selected using QGIS but I didn't manage to implement it. Do you guys have an example of a code using it, as the need is :

  1. Select the features from the map
  2. Click on the plugin button to peform the operation

closed as off-topic by PolyGeo Mar 3 '18 at 20:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • As a start for brainstorming, I was using this code : for feat in lyr.selectedFeatures : code... But as I said, the slection does not respect the order of selection. – Nekkini Mar 3 '18 at 20:18
  • I tried it out in QGIS 3 and my adaptation of link's code worked as expected. Please, put your code in your question for possible reopening it. – xunilk Mar 3 '18 at 23:09